View in MAUI WPF WinUI View on GitHub

Perform an exploratory viewshed analysis from a defined vantage point.

Image of exploratory show viewshed from point in scene

Use case

An exploratory viewshed analysis is a type of visual analysis you can perform at the current rendered resolution of a scene. The exploratory viewshed shows what can be seen 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).

Note: This analysis is a form of “exploratory analysis”, which means the results are calculated on the current scale of the data, and the results are generated very quickly but not persisted. If persisted analysis performed at the full resolution of the data is required, consider using a ViewshedFunction to perform a viewshed calculation instead.

How to use the sample

Use the sliders to change the properties (heading, pitch, etc.) of the exploratory viewshed and see them updated in real time. Tap on the map to move the exploratory viewshed.

How it works

  1. Create an ExploratoryLocationViewshed passing in the observer location, heading, pitch, horizontal/vertical angles, and min/max distances.
  2. Set the property values on the exploratory viewshed instance for location, direction, range, and visibility properties.

Relevant API

  • AnalysisOverlay
  • ArcGISSceneLayer
  • ArcGISTiledElevationSource
  • ExploratoryLocationViewshed
  • ExploratoryViewshed

About the data

The scene shows a buildings layer in Brest, France hosted on ArcGIS Online.

Tags

3D, exploratory viewshed, frustum, scene, visibility analysis

Sample Code

ShowExploratoryViewshedFromPointInScene.xaml ShowExploratoryViewshedFromPointInScene.xaml ShowExploratoryViewshedFromPointInScene.xaml.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGIS.Samples.ShowExploratoryViewshedFromPointInScene.ShowExploratoryViewshedFromPointInScene"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid Style="{DynamicResource EsriSampleContainer}">
<esriUI:SceneView x:Name="MySceneView" Style="{DynamicResource EsriSampleGeoView}" />
<Border Style="{DynamicResource EsriSampleControlPanel}">
<ScrollView>
<Grid ColumnDefinitions="auto,*"
ColumnSpacing="5"
RowDefinitions="auto,auto,auto,auto,auto,auto,auto,auto,auto,auto"
RowSpacing="10">
<Label Grid.Row="0"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Heading
</Label>
<Label Grid.Row="1"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Pitch
</Label>
<Label Grid.Row="2"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Horizontal Angle
</Label>
<Label Grid.Row="3"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Vertical Angle
</Label>
<Label Grid.Row="4"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Minimum Distance
</Label>
<Label Grid.Row="5"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Maximum Distance
</Label>
<Label Grid.Row="6"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Frustum Visibility
</Label>
<Label Grid.Row="7"
Grid.Column="0"
HorizontalTextAlignment="End"
VerticalTextAlignment="Center">
Analysis Visibility
</Label>
<Slider x:Name="HeadingSlider"
Grid.Row="0"
Grid.Column="1"
Maximum="360"
MaximumTrackColor="CadetBlue"
MinimumTrackColor="CadetBlue"
ValueChanged="HandleSettingsChange"
Value="0" />
<Slider x:Name="PitchSlider"
Grid.Row="1"
Grid.Column="1"
Maximum="180"
MaximumTrackColor="CadetBlue"
MinimumTrackColor="CadetBlue"
ValueChanged="HandleSettingsChange"
Value="60" />
<Slider x:Name="HorizontalAngleSlider"
Grid.Row="2"
Grid.Column="1"
Maximum="120"
MaximumTrackColor="CadetBlue"
Minimum="1"
MinimumTrackColor="CadetBlue"
ValueChanged="HandleSettingsChange"
Value="75" />
<Slider x:Name="VerticalAngleSlider"
Grid.Row="3"
Grid.Column="1"
Maximum="120"
MaximumTrackColor="CadetBlue"
Minimum="1"
MinimumTrackColor="CadetBlue"
ValueChanged="HandleSettingsChange"
Value="90" />
<Slider x:Name="MinimumDistanceSlider"
Grid.Row="4"
Grid.Column="1"
Maximum="8999"
MaximumTrackColor="CadetBlue"
Minimum="5"
MinimumTrackColor="CadetBlue"
ValueChanged="HandleSettingsChange"
Value="5" />
<Slider x:Name="MaximumDistanceSlider"
Grid.Row="5"
Grid.Column="1"
Maximum="9999"
MaximumTrackColor="CadetBlue"
MinimumTrackColor="CadetBlue"
ValueChanged="HandleSettingsChange"
Value="1500" />
<Switch x:Name="FrustumVisibilityCheck"
Grid.Row="6"
Grid.Column="1"
HorizontalOptions="Start"
Toggled="HandleSettingsChange" />
<Switch x:Name="AnalysisVisibilityCheck"
Grid.Row="7"
Grid.Column="1"
HorizontalOptions="Start"
IsToggled="True"
Toggled="HandleSettingsChange" />
<Label Grid.Row="8"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalOptions="Center">
Tap scene to change viewshed location.
</Label>
</Grid>
</ScrollView>
</Border>
</Grid>
</ContentPage>