Viewshed (location)

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Perform a viewshed analysis from a defined vantage point.

Image of viewshed location

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

  1. Create a LocationViewshed passing in the observer location, heading, pitch, horizontal/vertical angles, and min/max distances.
  2. 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

ViewshedLocation.xamlViewshedLocation.xaml.cs
                                                                                                                                        
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ViewshedLocation.ViewshedLocation"
             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 Text="Tap to pick up the observer, tap again to drop it."
                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"
                           Margin="0,0,0,10"
                           TextWrapping="WrapWithOverflow" TextAlignment="Center" FontWeight="SemiBold" />

                <TextBlock Text="Heading"
                           Grid.Row="1" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Pitch"
                           Grid.Row="2" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Horizontal angle"
                           Grid.Row="3" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Vertical angle"
                           Grid.Row="4" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Height"
                           Grid.Row="5" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Minimum distance"
                           Grid.Row="6" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Maximum distance"
                           Grid.Row="7" Grid.Column="0"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Frustum visibility"
                           Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="2"
                           HorizontalAlignment="Right" />
                <TextBlock Text="Analysis visibility"
                           Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2"
                           HorizontalAlignment="Right" />

                <Slider x:Name="HeadingSlider"
                        Grid.Row="1" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="0" Maximum="360"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <Slider x:Name="PitchSlider"
                        Grid.Row="2" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="60" Maximum="180"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <Slider x:Name="HorizontalAngleSlider"
                        Grid.Row="3" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="75" Maximum="120" Minimum="1"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <Slider x:Name="VerticalAngleSlider"
                        Grid.Row="4" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="90" Maximum="120" Minimum="1"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <Slider x:Name="HeightSlider"
                        Grid.Row="5" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="10" Maximum="200" Minimum="0"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <Slider x:Name="MinimumDistanceSlider"
                        Grid.Row="6" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="5" Maximum="8999" Minimum="5"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <Slider x:Name="MaximumDistanceSlider"
                        Grid.Row="7" Grid.Column="1"
                        HorizontalAlignment="Stretch" VerticalAlignment="Center"
                        Value="1500" Minimum="1" Maximum="9999"
                        TickFrequency="1" IsSnapToTickEnabled="True"
                        ValueChanged="HandleSettingsChange" />
                <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"
                          IsChecked="True"
                          Checked="HandleSettingsChange"
                          Unchecked="HandleSettingsChange" />

                <Label Content="{Binding Value, ElementName=HeadingSlider}"
                       Grid.Row="1" Grid.Column="2" />
                <Label Content="{Binding Value, ElementName=PitchSlider}"
                       Grid.Row="2" Grid.Column="2" />
                <Label Content="{Binding Value, ElementName=HorizontalAngleSlider}"
                       Grid.Row="3" Grid.Column="2" />
                <Label Content="{Binding Value, ElementName=VerticalAngleSlider}"
                       Grid.Row="4" Grid.Column="2" />
                <Label Content="{Binding Value, ElementName=HeightSlider}"
                       Grid.Row="5" Grid.Column="2" />
                <Label Content="{Binding Value, ElementName=MinimumDistanceSlider}"
                       Grid.Row="6" Grid.Column="2" />
                    <Label Content="{Binding Value, ElementName=MaximumDistanceSlider}"
                       Grid.Row="7" Grid.Column="2" />
            </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.