Apply an RGB renderer to a raster layer to enhance feature visibility.
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
- Create a
Raster
from a from a multispectral raster file. - Create a
RasterLayer
from the raster. - Create a
Basemap
from the raster layer and set it to the map. - Create an
RGBRenderer
, specifying theStretchParameters
and other properties. - 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:
- raster-file.zip - Tif raster file
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
<UserControl x:Class="ArcGISRuntime.WPF.Samples.RasterRgbRenderer.RasterRgbRenderer"
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" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="ComboBox">
<Setter Property="Margin" Value="5" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="MaxHeight" Value="25" />
</Style>
<Style TargetType="Slider">
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</UserControl.Resources>
<Grid>
<esri:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Stretch type selection -->
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="Stretch type: " />
<ComboBox x:Name="StretchTypeComboBox"
Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Stretch"
SelectionChanged="StretchTypeComboBox_SelectionChanged" />
<!-- Min/Max form -->
<Grid x:Name="MinMaxParametersGrid"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Visibility="Visible">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
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>
<!-- Percent clip form -->
<Grid x:Name="PercentClipParametersGrid"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="Minimum %: " />
<Slider x:Name="MinimumValueSlider"
Grid.Row="0"
Grid.Column="1"
Maximum="100"
Minimum="0" />
<TextBlock Grid.Row="1"
Grid.Column="0"
Text="Maximum %: " />
<Slider x:Name="MaximumValueSlider"
Grid.Row="1"
Grid.Column="1"
Maximum="100"
Minimum="0" />
</Grid>
<!-- Standard deviation form -->
<Grid x:Name="StdDeviationParametersGrid"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Text="Factor:" />
<ComboBox x:Name="StdDeviationFactorComboBox"
Grid.Row="0"
Grid.Column="1" />
</Grid>
<!-- Apply button -->
<Button x:Name="ApplyRgbRendererButton"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="5"
Click="ApplyRgbRendererButton_Click"
Content="Apply renderer"
IsEnabled="False" />
</Grid>
</Border>
</Grid>
</UserControl>