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
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.RasterRgbRenderer.RasterRgbRenderer"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="220" />
</Grid.RowDefinitions>
<esriUI:MapView x:Name="MyMapView" Grid.Row="0" />
<Grid Grid.Row="1"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand"
WidthRequest="400">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Orientation="Horizontal">
<Label Margin="10,0,3,0"
HorizontalOptions="End"
MinimumWidthRequest="80"
Text="Stretch: "
VerticalOptions="CenterAndExpand" />
<Picker x:Name="StretchTypeComboBox"
SelectedIndexChanged="StretchTypeSelectionChanged"
VerticalOptions="CenterAndExpand" />
</StackLayout>
<Grid x:Name="MinMaxParametersGrid"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="4"
Margin="0,10"
IsVisible="True">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="0"
Grid.Column="0"
Margin="0,0,3,0"
HorizontalOptions="End"
Text="Min: "
VerticalOptions="CenterAndExpand" />
<Picker x:Name="MinRedComboBox"
Grid.Row="0"
Grid.Column="1"
HeightRequest="40"
HorizontalOptions="Center"
TextColor="Red"
VerticalOptions="CenterAndExpand"
WidthRequest="80" />
<Picker x:Name="MinGreenComboBox"
Grid.Row="0"
Grid.Column="2"
HeightRequest="40"
HorizontalOptions="Center"
TextColor="Green"
VerticalOptions="CenterAndExpand"
WidthRequest="80" />
<Picker x:Name="MinBlueComboBox"
Grid.Row="0"
Grid.Column="3"
HeightRequest="40"
HorizontalOptions="Center"
TextColor="Blue"
VerticalOptions="CenterAndExpand"
WidthRequest="80" />
<Label Grid.Row="1"
Grid.Column="0"
Margin="0,0,3,0"
HorizontalOptions="End"
Text="Max: "
VerticalOptions="CenterAndExpand" />
<Picker x:Name="MaxRedComboBox"
Grid.Row="1"
Grid.Column="1"
HeightRequest="40"
HorizontalOptions="Center"
TextColor="Red"
VerticalOptions="CenterAndExpand"
WidthRequest="80" />
<Picker x:Name="MaxGreenComboBox"
Grid.Row="1"
Grid.Column="2"
HeightRequest="40"
HorizontalOptions="Center"
TextColor="Green"
VerticalOptions="CenterAndExpand"
WidthRequest="80" />
<Picker x:Name="MaxBlueComboBox"
Grid.Row="1"
Grid.Column="3"
HeightRequest="40"
HorizontalOptions="Center"
TextColor="Blue"
VerticalOptions="CenterAndExpand"
WidthRequest="80" />
</Grid>
<Grid x:Name="PercentClipParametersGrid"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="4"
IsVisible="False">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0"
Grid.Column="0"
HorizontalOptions="Center"
Text="Min %: "
VerticalOptions="CenterAndExpand" />
<Slider x:Name="MinimumValueSlider"
Grid.Row="0"
Grid.Column="1"
Margin="20,0"
Maximum="100"
MaximumTrackColor="CadetBlue"
Minimum="0"
MinimumTrackColor="CadetBlue"
VerticalOptions="CenterAndExpand" />
<Label Grid.Row="1"
Grid.Column="0"
HorizontalOptions="Center"
Text="Max %: "
VerticalOptions="CenterAndExpand" />
<Slider x:Name="MaximumValueSlider"
Grid.Row="1"
Grid.Column="1"
Margin="20,0"
Maximum="100"
MaximumTrackColor="CadetBlue"
Minimum="0"
MinimumTrackColor="CadetBlue"
VerticalOptions="CenterAndExpand" />
</Grid>
<Grid x:Name="StdDeviationParametersGrid"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="4"
IsVisible="False">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="1"
Grid.Column="0"
HorizontalOptions="Center"
Text="Factor: "
VerticalOptions="CenterAndExpand" />
<Picker x:Name="StdDeviationFactorComboBox"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand"
WidthRequest="60" />
</Grid>
<Button x:Name="ApplyRgbRendererButton"
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="0,5"
Clicked="ApplyRgbRendererButton_Clicked"
HeightRequest="40"
HorizontalOptions="Center"
IsEnabled="False"
Text="Apply renderer"
VerticalOptions="End" />
</Grid>
</Grid>
</ContentPage>