View on GitHub Sample viewer app

Blend a hillshade with a raster by specifying the elevation data. The resulting raster looks similar to the original raster, but with some terrain shading, giving it a textured look.

Image of apply blend renderer to hillshade sample

Use case

BlendRenderer can be used to apply a color ramp to a hillshade to emphasize areas of high or low elevation. A BlendRenderer can also be used to add a hillshade effect to aerial or satellite imagery, thereby making changes in elevation more visible.

How to use the sample

Choose and adjust the altitude, azimuth, slope type and color ramp type settings to update the image.

How it works

  1. Create a Raster object from a raster file.
  2. Create a RasterLayer object from the raster.
  3. Create a Basemap object from the raster layer and set it to the map.
  4. Create another Raster object for elevation from a grayscale raster file.
  5. Create a BlendRenderer object, specifying the elevation raster, color ramp, and other properties.
  • If you specify a non-null color ramp, use the elevation raster as the base raster in addition to the elevation raster parameter. That way, the color ramp is used instead of the satellite imagery.
  1. Set the blend renderer to the raster layer.

Relevant API

  • BlendRenderer
  • ColorRamp
  • Raster
  • RasterLayer

Offline data

This sample uses the Shasta Raster and Shasta Elevation Raster. Both are downloaded from ArcGIS Online automatically.

Tags

color ramp, elevation, hillshade, image, raster, raster layer, visualization

Sample Code

DownloadActivity.kt DownloadActivity.kt MainActivity.kt ApplyBlendRendererToHillshadeViewModel.kt ApplyBlendRendererToHillshadeScreen.kt
/* Copyright 2025 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.esri.arcgismaps.sample.applyblendrenderertohillshade
import android.content.Intent
import android.os.Bundle
import com.esri.arcgismaps.sample.sampleslib.DownloaderActivity
class DownloadActivity : DownloaderActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
downloadAndStartSample(
Intent(this, MainActivity::class.java),
getString(R.string.apply_blend_renderer_to_hillshade_app_name),
listOf(
"https://www.arcgis.com/home/item.html?id=7c4c679ab06a4df19dc497f577f111bd",
"https://www.arcgis.com/home/item.html?id=b051f5c3e01048f3bf11c59b41507896"
)
)
}
}