Viewshed for GeoElement

View inMAUIUWPWPFWinUIView on GitHub

Analyze the viewshed for an object (GeoElement) in a scene.

Image of viewshed for geoelement

Use case

A viewshed analysis is a type of visual analysis you can perform on a scene. The viewshed aims to answer the question 'What can I see from a given location?'. The output is an overlay with two different colors - one representing the visible areas (green) and the other representing the obstructed areas (red).

How to use the sample

Tap to set a destination for the vehicle (a GeoElement). The vehicle will 'drive' towards the tapped location. The viewshed analysis will update as the vehicle moves.

How it works

  1. Create and show the scene, with an elevation source and a buildings layer.
  2. Add a model (the GeoElement) to represent the observer (in this case, a tank).
    • Use a SimpleRenderer which has a heading expression set in the GraphicsOverlay. This way you can relate the viewshed's heading to the GeoElement object's heading.
  3. Create a GeoElementViewshed with configuration for the viewshed analysis.
  4. Add the viewshed to an AnalysisOverlay and add the overlay to the scene.
  5. Configure the SceneView CameraController to orbit the vehicle.

Relevant API

  • AnalysisOverlay
  • GeodeticDistanceResult
  • GeoElementViewshed
  • GeometryEngine.DistanceGeodetic
  • ModelSceneSymbol
  • OrbitGeoElementCameraController

Offline data

This sample downloads the following items from ArcGIS Online automatically:

About the data

This sample shows a Johannesburg, South Africa Scene from ArcGIS Online. The sample uses a Tank model scene symbol hosted as an item on ArcGIS Online.

Tags

3D, analysis, buildings, model, scene, viewshed, visibility analysis

Sample Code

ViewshedGeoElement.xamlViewshedGeoElement.xamlViewshedGeoElement.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<UserControl
    x:Class="ArcGIS.UWP.Samples.ViewshedGeoElement.ViewshedGeoElement"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:SceneView x:Name="MySceneView" />
        <Border Style="{StaticResource BorderStyle}">
            <TextBlock Text="Tap to set a destination for the vehicle."
                       TextAlignment="Center"
                       FontWeight="SemiBold" />
        </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.