View in MAUI WPF WinUI View on GitHub Sample viewer app

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. Click 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
<UserControl x:Class="ArcGIS.WPF.Samples.ShowExploratoryViewshedFromPointInScene.ShowExploratoryViewshedFromPointInScene"
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">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="0,0,5,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</UserControl.Resources>
<Grid>
<esri:SceneView x:Name="MySceneView" />
<Border Style="{StaticResource BorderStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="0,0,0,10"
FontWeight="SemiBold"
Text="Tap to pick up the observer, tap again to drop it."
TextAlignment="Center"
TextWrapping="WrapWithOverflow" />
<TextBlock Grid.Row="1"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Heading" />
<TextBlock Grid.Row="2"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Pitch" />
<TextBlock Grid.Row="3"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Horizontal angle" />
<TextBlock Grid.Row="4"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Vertical angle" />
<TextBlock Grid.Row="5"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Height" />
<TextBlock Grid.Row="6"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Minimum distance" />
<TextBlock Grid.Row="7"
Grid.Column="0"
HorizontalAlignment="Right"
Text="Maximum distance" />
<TextBlock Grid.Row="8"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalAlignment="Right"
Text="Frustum visibility" />
<TextBlock Grid.Row="9"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalAlignment="Right"
Text="Analysis visibility" />
<Slider x:Name="HeadingSlider"
Grid.Row="1"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="360"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="0" />
<Slider x:Name="PitchSlider"
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="180"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="60" />
<Slider x:Name="HorizontalAngleSlider"
Grid.Row="3"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="120"
Minimum="1"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="75" />
<Slider x:Name="VerticalAngleSlider"
Grid.Row="4"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="120"
Minimum="1"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="90" />
<Slider x:Name="HeightSlider"
Grid.Row="5"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="200"
Minimum="0"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="10" />
<Slider x:Name="MinimumDistanceSlider"
Grid.Row="6"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="8999"
Minimum="5"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="5" />
<Slider x:Name="MaximumDistanceSlider"
Grid.Row="7"
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="9999"
Minimum="1"
TickFrequency="1"
ValueChanged="HandleSettingsChange"
Value="1500" />
<CheckBox x:Name="FrustumVisibilityCheck"
Grid.Row="8"
Grid.Column="2"
Margin="5"
VerticalAlignment="Center"
Checked="HandleSettingsChange"
Unchecked="HandleSettingsChange" />
<CheckBox x:Name="AnalysisVisibilityCheck"
Grid.Row="9"
Grid.Column="2"
Margin="5"
VerticalAlignment="Center"
Checked="HandleSettingsChange"
IsChecked="True"
Unchecked="HandleSettingsChange" />
<Label Grid.Row="1"
Grid.Column="2"
Content="{Binding Value, ElementName=HeadingSlider}" />
<Label Grid.Row="2"
Grid.Column="2"
Content="{Binding Value, ElementName=PitchSlider}" />
<Label Grid.Row="3"
Grid.Column="2"
Content="{Binding Value, ElementName=HorizontalAngleSlider}" />
<Label Grid.Row="4"
Grid.Column="2"
Content="{Binding Value, ElementName=VerticalAngleSlider}" />
<Label Grid.Row="5"
Grid.Column="2"
Content="{Binding Value, ElementName=HeightSlider}" />
<Label Grid.Row="6"
Grid.Column="2"
Content="{Binding Value, ElementName=MinimumDistanceSlider}" />
<Label Grid.Row="7"
Grid.Column="2"
Content="{Binding Value, ElementName=MaximumDistanceSlider}" />
</Grid>
</Border>
</Grid>
</UserControl>