Analyze viewshed (geoprocessing)

View inAndroidFormsUWPWPFWinUIiOSView on GitHubSample viewer app

Calculate a viewshed using a geoprocessing service, in this case showing what parts of a landscape are visible from points on mountainous terrain.

Image of viewshed geoprocessing

Use case

A viewshed is used to highlight what is visible from a given point. A viewshed could be created to show what a hiker might be able to see from a given point at the top of a mountain. Equally, a viewshed could also be created from a point representing the maximum height of a proposed wind turbine to see from what areas the turbine would be visible.

How to use the sample

Click the map to see all areas visible from that point within a 15km radius. Clicking on an elevated area will highlight a larger part of the surrounding landscape. It may take a few seconds for the task to run and send back the results.

How it works

  1. Create a GeoprocessingTask object with the URL set to a geoprocessing service endpoint.
  2. Create a FeatureCollectionTable object and add a new Feature object whose geometry is the viewshed's observer Point.
  3. Make a GeoprocessingParameters object passing in the observer point.
  4. Use the geoprocessing task to create a GeoprocessingJob object with the parameters.
  5. Start the job and wait for it to complete and return a GeoprocessingResult object.
  6. Get the resulting GeoprocessingFeatures object.
  7. Iterate through the viewshed features to use their geometry or display the geometry in a new Graphic object.

Relevant API

  • FeatureCollectionTable
  • GeoprocessingFeatures
  • GeoprocessingJob
  • GeoprocessingParameters
  • GeoprocessingResult
  • GeoprocessingTask

Tags

geoprocessing, heat map, heatmap, viewshed

Sample Code

AnalyzeViewshed.xamlAnalyzeViewshed.xamlAnalyzeViewshed.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
<UserControl x:Class="ArcGISRuntime.WPF.Samples.AnalyzeViewshed.AnalyzeViewshed"
             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 Margin="20">
                <TextBlock HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Text="Click map to execute viewshed analysis." />

                <Grid x:Name="BusyOverlay"
                      Grid.RowSpan="4"
                      Margin="-20"
                      Background="#8C000000"
                      Visibility="Collapsed">
                    <Border Padding="10"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Background="#FFC6C4C4">
                        <Grid>
                            <ProgressBar x:Name="Progress"
                                         Height="20"
                                         IsIndeterminate="True" />
                            <TextBlock Height="20"
                                       Margin="5"
                                       HorizontalAlignment="Center"
                                       Text="Executing analysis..." />
                        </Grid>
                    </Border>
                </Grid>
            </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.