Stretch renderer

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Use a stretch renderer to enhance the visual contrast of raster data for analysis.

Image of stretch renderer

Use case

An appropriate stretch renderer can enhance the contrast of raster imagery, allowing the user to control how their data is displayed for efficient imagery analysis.

How to use the sample

Choose one of the stretch parameter types:

  • Standard deviation - a linear stretch defined by the standard deviation of the pixel values
  • Min-max - a linear stretch based on minimum and maximum pixel values
  • Percent clip - a linear stretch between the defined percent clip minimum and percent clip maximum pixel values

Then configure the parameters and tap 'Update renderer'.

How it works

  1. Create a Raster from a raster file.
  2. Create a RasterLayer from the Raster.
  3. Add the layer to the map.
  4. Create a StretchRenderer, specifying the stretch parameters and other properties.
  5. Apply the Renderer to the raster layer.

Relevant API

  • ColorRamp
  • MinMaxStretchParameters
  • PercentClipStretchParameters
  • Raster
  • RasterLayer
  • StandardDeviationStretchParameters
  • StretchParameters
  • StretchRenderer

Offline data

This sample downloads the following items from ArcGIS Online automatically:

About the data

This sample uses a raster imagery tile of an area of forested mountainous terrain and rivers.

Additional information

See Stretch function in the ArcMap documentation for more information about the types of stretches that can be performed.

Tags

analysis, deviation, histogram, imagery, interpretation, min-max, percent clip, pixel, raster, stretch, symbology, visualization

Sample Code

ChangeStretchRenderer.xamlChangeStretchRenderer.xamlChangeStretchRenderer.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
<ContentPage x:Class="ArcGISRuntime.Samples.ChangeStretchRenderer.ChangeStretchRenderer"
             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 Height="auto" />
            <RowDefinition Height="100" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Label Grid.Row="0">Choose a stretch renderer type from the listbox, adjust the parameter values, then click the 'Update Renderer' button.</Label>
        <ListView x:Name="RendererTypes"
                  Grid.Row="1"
                  ItemSelected="RendererTypes_SelectionChanged" />
        <StackLayout Grid.Row="2"
                     Margin="5"
                     Orientation="Horizontal">
            <Label x:Name="Label_Parameter1"
                   Text="Parameter1"
                   VerticalOptions="Center" />
            <Entry x:Name="Input_Parameter1"
                   HorizontalOptions="FillAndExpand"
                   Keyboard="Numeric"
                   Text="EnterValue1" />
        </StackLayout>
        <StackLayout Grid.Row="3"
                     Margin="5"
                     Orientation="Horizontal">
            <Label x:Name="Label_Parameter2"
                   Text="Parameter2"
                   VerticalOptions="Center" />
            <Entry x:Name="Input_Parameter2"
                   HorizontalOptions="FillAndExpand"
                   Keyboard="Numeric"
                   Text="EnterValue2" />
        </StackLayout>
        <Button x:Name="UpdateRenderer"
                Grid.Row="4"
                Clicked="OnUpdateRendererClicked"
                Text="Update Renderer" />
        <esriUI:MapView x:Name="MyMapView" Grid.Row="5" />
    </Grid>
</ContentPage>

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