RGB renderer

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Apply an RGB renderer to a raster layer to enhance feature visibility.

Image of RGB renderer

Use case

An RGB renderer is used to adjust the color bands of a multispectral image. Remote sensing images acquired from satellites often contain values representing the reflection of multiple spectrums of light. Changing the RGB renderer of such rasters can be used to differentiate and highlight particular features that reflect light differently, such as different vegetation types, or turbidity in water.

How to use the sample

Choose one of the stretch parameter types. The other options will adjust based on the chosen type. Add your inputs and select the 'Update' button to update the renderer.

How it works

  1. Create a Raster from a from a multispectral raster file.
  2. Create a RasterLayer from the raster.
  3. Create a Basemap from the raster layer and set it to the map.
  4. Create an RGBRenderer, specifying the StretchParameters and other properties.
  5. Apply the renderer to the raster layer.

Relevant API

  • Basemap
  • Raster
  • RasterLayer
  • RGBRenderer
  • StretchParameters

Offline data

This sample downloads the following items from ArcGIS Online automatically:

About the data

The raster used in this sample shows an area in the south of the Shasta-Trinity National Forest, California.

Tags

analysis, color, composite, imagery, multiband, multispectral, pan-sharpen, photograph, raster, spectrum, stretch, visualization

Sample Code

RasterRgbRenderer.xamlRasterRgbRenderer.xamlRasterRgbRenderer.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.RasterRgbRenderer.RasterRgbRenderer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <UserControl.Resources>
        <Style TargetType="ComboBox">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="5,5,0,0" />
        </Style>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="FontWeight" Value="SemiBold" />
        </Style>
        <Style TargetType="Slider">
            <Setter Property="Minimum" Value="0" />
            <Setter Property="Maximum" Value="100" />
            <Setter Property="Padding" Value="5,8,0,0" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" MinWidth="100" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           HorizontalAlignment="Right"
                           VerticalAlignment="Center"
                           Text="Stretch type: " />
                <ComboBox x:Name="StretchTypeComboBox"
                          Grid.Row="0"
                          Grid.Column="1"
                          Grid.ColumnSpan="3"
                          SelectionChanged="StretchTypeComboBox_SelectionChanged" />
                <Grid x:Name="MinMaxParametersGrid"
                      Grid.Row="1"
                      Grid.Column="0"
                      Grid.ColumnSpan="4"
                      Margin="0,0,0,5"
                      Visibility="Visible">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MinWidth="100" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Row="0"
                               Grid.Column="0"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Center"
                               Text="Min value: " />
                    <ComboBox x:Name="MinRedComboBox"
                              Grid.Row="0"
                              Grid.Column="1"
                              Foreground="Red" />
                    <ComboBox x:Name="MinGreenComboBox"
                              Grid.Row="0"
                              Grid.Column="2"
                              Foreground="Green" />
                    <ComboBox x:Name="MinBlueComboBox"
                              Grid.Row="0"
                              Grid.Column="3"
                              Foreground="Blue" />
                    <TextBlock Grid.Row="1"
                               Grid.Column="0"
                               Text="Max value: " />
                    <ComboBox x:Name="MaxRedComboBox"
                              Grid.Row="1"
                              Grid.Column="1"
                              Foreground="Red" />
                    <ComboBox x:Name="MaxGreenComboBox"
                              Grid.Row="1"
                              Grid.Column="2"
                              Foreground="Green" />
                    <ComboBox x:Name="MaxBlueComboBox"
                              Grid.Row="1"
                              Grid.Column="3"
                              Foreground="Blue" />
                </Grid>
                <Grid x:Name="PercentClipParametersGrid"
                      Grid.Row="1"
                      Grid.Column="0"
                      Grid.ColumnSpan="4"
                      Visibility="Collapsed">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MinWidth="100" />
                        <ColumnDefinition Width="3*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Row="0"
                               Grid.Column="0"
                               Text="Minimum %:" />
                    <Slider x:Name="MinimumValueSlider"
                            Grid.Row="0"
                            Grid.Column="1" />
                    <TextBlock Grid.Row="1"
                               Grid.Column="0"
                               Text="Maximum %: " />
                    <Slider x:Name="MaximumValueSlider"
                            Grid.Row="1"
                            Grid.Column="1" />
                </Grid>
                <Grid x:Name="StdDeviationParametersGrid"
                      Grid.Row="1"
                      Grid.Column="0"
                      Grid.ColumnSpan="4"
                      Visibility="Collapsed">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" MinWidth="100" />
                        <ColumnDefinition Width="3*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="Factor: " />
                    <ComboBox x:Name="StdDeviationFactorComboBox"
                              Grid.Column="1"
                              Margin="5,5,0,5" />
                </Grid>
                <Button x:Name="ApplyRgbRendererButton"
                        Grid.Row="2"
                        Grid.Column="0"
                        Grid.ColumnSpan="4"
                        HorizontalAlignment="Stretch"
                        Click="ApplyRgbRendererButton_Click"
                        Content="Apply 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.