Perform a viewshed analysis from a defined vantage point.
Use case
A 3D viewshed analysis is a type of visual analysis you can perform on a scene. The 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). Viewshed 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. If more "conclusive" results are required, consider using a GeoprocessingTask
to perform a viewshed instead.
How to use the sample
Use the sliders to change the properties (heading, pitch, etc.), of the viewshed and see them updated in real time.
How it works
- Create a
LocationViewshed
passing in the observer location, heading, pitch, horizontal/vertical angles, and min/max distances. - Set the property values on the viewshed instance for location, direction, range, and visibility properties.
Relevant API
- AnalysisOverlay
- ArcGISSceneLayer
- ArcGISTiledElevationSource
- LocationViewshed
- Viewshed
About the data
The scene shows a buildings layer in Brest, France hosted on ArcGIS Online.
Tags
3D, frustum, scene, viewshed, visibility analysis
Sample Code
<UserControl
x:Class="ArcGISRuntime.UWP.Samples.ViewshedLocation.ViewshedLocation"
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">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,5,10" />
</Style>
<Style TargetType="Slider">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="SnapsTo" Value="StepValues" />
<Setter Property="StepFrequency" Value="1" />
</Style>
</UserControl.Resources>
<Grid>
<esriUI:SceneView x:Name="MySceneView" />
<Border Style="{StaticResource BorderStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Heading"
Grid.Row="0" Grid.Column="0" />
<TextBlock Text="Pitch"
Grid.Row="1" Grid.Column="0" />
<TextBlock Text="Horizontal angle"
Grid.Row="2" Grid.Column="0" />
<TextBlock Text="Vertical angle"
Grid.Row="3" Grid.Column="0" />
<TextBlock Text="Height"
Grid.Row="4" Grid.Column="0" />
<TextBlock Text="Minimum distance"
Grid.Row="5" Grid.Column="0" />
<TextBlock Text="Maximum distance"
Grid.Row="6" Grid.Column="0" />
<TextBlock Text="Frustum visibility"
Grid.Row="7" Grid.Column="0" />
<TextBlock Text="Analysis visibility"
Grid.Row="8" Grid.Column="0" />
<Slider x:Name="HeadingSlider"
Grid.Row="0" Grid.Column="1"
Value="0" Maximum="360"
ValueChanged="HandleSettingsChange" />
<Slider x:Name="PitchSlider"
Grid.Row="1" Grid.Column="1"
Value="60" Maximum="180"
ValueChanged="HandleSettingsChange" />
<Slider x:Name="HorizontalAngleSlider"
Grid.Row="2" Grid.Column="1"
Value="75" Maximum="120" Minimum="1"
ValueChanged="HandleSettingsChange" />
<Slider x:Name="VerticalAngleSlider"
Grid.Row="3" Grid.Column="1"
Value="90" Maximum="120" Minimum="1"
ValueChanged="HandleSettingsChange" />
<Slider x:Name="HeightSlider"
Grid.Row="4" Grid.Column="1"
Value="10" Maximum="200" Minimum="0"
ValueChanged="HandleSettingsChange" />
<Slider x:Name="MinimumDistanceSlider"
Grid.Row="5" Grid.Column="1"
Value="5" Maximum="8999" Minimum="5"
ValueChanged="HandleSettingsChange" />
<Slider x:Name="MaximumDistanceSlider"
Grid.Row="6" Grid.Column="1"
Value="1500" Minimum="1" Maximum="9999"
ValueChanged="HandleSettingsChange" />
<CheckBox x:Name="FrustumVisibilityCheck"
Grid.Row="7" Grid.Column="1"
VerticalAlignment="Center"
Checked="HandleSettingsChange"
Unchecked="HandleSettingsChange" />
<CheckBox x:Name="AnalysisVisibilityCheck"
Grid.Row="8" Grid.Column="1"
VerticalAlignment="Center"
Checked="HandleSettingsChange"
Unchecked="HandleSettingsChange" IsChecked="True" />
<TextBlock Text="Tap to change the viewshed location."
Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2"
FontWeight="SemiBold" HorizontalAlignment="Center"
Margin="0,5,0,0"/>
</Grid>
</Border>
</Grid>
</UserControl>