Blend renderer

View inAndroidFormsUWPWPFWinUIiOSView on GitHubSample 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 blend renderer

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.
  6. Set the blend renderer to the raster layer.

Relevant API

  • BlendRenderer
  • ColorRamp
  • Raster
  • RasterLayer

Offline data

This sample uses the Shasta elevation image collection.

Tags

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

Sample Code

ChangeBlendRenderer.xamlChangeBlendRenderer.xamlChangeBlendRenderer.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ChangeBlendRenderer.ChangeBlendRenderer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Margin" Value="5,5,5,5" />
            <Setter Property="FontWeight" Value="SemiBold" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Margin" Value="5,5,5,5" />
        </Style>
        <Style TargetType="Slider">
            <Setter Property="Margin" Value="5,5,5,5" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           Grid.ColumnSpan="2"
                           Margin="5"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           FontWeight="Normal"
                           Text="Tap on the 'Update renderer' button to change the settings for the blend renderer. The sample allows you to change the Altitude, Azimuth, SlopeType and ColorRamp. If you use None as the ColorRamp, a standard hill shade raster output is displayed. For all the other ColorRamp types an elevation raster is used."
                           TextWrapping="Wrap" />
                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           Text="Altitude" />
                <Slider x:Name="AltitudeSlider"
                        Grid.Row="1"
                        Grid.Column="1"
                        Maximum="90"
                        Minimum="0"
                        Value="45">
                    <Slider.ToolTip>
                        <ToolTip Content="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget.Value}" ContentStringFormat="{}{0:0}" />
                    </Slider.ToolTip>
                </Slider>
                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           Text="Azimuth" />
                <Slider x:Name="AzimuthSlider"
                        Grid.Row="2"
                        Grid.Column="1"
                        Maximum="360"
                        Minimum="0"
                        Value="180">
                    <Slider.ToolTip>
                        <ToolTip Content="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget.Value}" ContentStringFormat="{}{0:0}" />
                    </Slider.ToolTip>
                </Slider>
                <TextBlock Grid.Row="3"
                           Grid.Column="0"
                           Text="Slope Type" />
                <ComboBox x:Name="SlopeTypes"
                          Grid.Row="3"
                          Grid.Column="1" />
                <TextBlock Grid.Row="4"
                           Grid.Column="0"
                           Text="Color Ramp" />
                <ComboBox x:Name="ColorRamps"
                          Grid.Row="4"
                          Grid.Column="1" />
                <Button x:Name="UpdateRenderer"
                        Grid.Row="5"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Margin="5"
                        Click="OnUpdateRendererClicked"
                        Content="Update renderer"
                        IsEnabled="False" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.