View in MAUI WPF WinUI View on GitHub Sample viewer app
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Create contour lines from local raster data using a local geoprocessing package

and the contour geoprocessing tool.

Image of local server geoprocessing

Use case

For executing offline geoprocessing tasks in your apps via an offline (local) server.

How to use the sample

Contour Line Controls (Top Left):

  • Interval - Specifies the spacing between contour lines.
  • Generate Contours - Adds contour lines to map using interval.
  • Clear Results - Removes contour lines from map.

How it works

  1. Create and run a local server with
    .
  2. Start the server asynchronously with
    .
  3. Start a
    and run a
    .
    1. Instantiate
      to create a local geoprocessing service.
    2. Call
      to start the service asynchronously.
    3. Instantiate
      to create a geoprocessing task that uses the contour lines tool.
  4. Create an instance of
    .
    1. Instantiate
      creates geoprocessing parameters.
    2. Create a parameter using
      using the desired contour value.
  5. Create and start a
    using the previous parameters.
    1. Create a geoprocessing job with
      .
    2. Start the job with
      .
  6. Add contour lines as an
    to the map.
    1. Get url from local geoprocessing service using the
      property.
    2. Get server job id of geoprocessing job using the
      property.
    3. Replace
      from url with
      , to get generate contour lines data.
    4. Create a map image layer from that new url and add that layer to the map.

Relevant API

  • GeoprocessingDouble
  • GeoprocessingJob
  • GeoprocessingParameter
  • GeoprocessingParameters
  • GeoprocessingTask
  • LocalGeoprocessingService
  • LocalGeoprocessingService.ServiceType
  • LocalServer
  • LocalServerStatus

Offline data

This sample downloads the following items from ArcGIS Online automatically:

Additional information

ArcGIS Maps SDK for Local Server (Local Server) is deprecated and will be retired in 2030. For more information, see the deprecation announcement.

Tags

geoprocessing, local, offline, parameters, processing, service

Sample Code

LocalServerGeoprocessing.xaml LocalServerGeoprocessing.xaml LocalServerGeoprocessing.xaml.cs
<UserControl x:Class="ArcGIS.WPF.Samples.LocalServerGeoprocessing.LocalServerGeoprocessing"
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">
<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" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="3"
FontWeight="SemiBold"
Text="Use the slider to select a contour interval (height difference between contour lines). Use the buttons to update or clear the contours."
TextWrapping="Wrap" />
<ProgressBar x:Name="MyLoadingIndicator"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
Height="15"
Margin="0,5,0,0"
IsIndeterminate="True" />
<Slider x:Name="MyContourSlider"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2"
Margin="0,5,0,0"
VerticalAlignment="Center"
Maximum="350"
Minimum="50" />
<TextBlock x:Name="MyContourDepthLabel"
Grid.Row="2"
Grid.Column="2"
Margin="0,5,0,0"
VerticalAlignment="Center"
Text="{Binding Value, ElementName=MyContourSlider, StringFormat=N2}"
TextAlignment="Center" />
<Button x:Name="MyUpdateContourButton"
Grid.Row="3"
Grid.Column="0"
Margin="0,5,5,0"
Click="MyUpdateContourButton_OnClick"
Content="Generate"
IsEnabled="False" />
<Button x:Name="MyResetButton"
Grid.Row="3"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="5,5,0,0"
Click="MyResetButton_OnClick"
Content="Reset"
IsEnabled="False" />
</Grid>
</Border>
</Grid>
</UserControl>