Interactive Viewshed Analysis Tutorial
In this tutorial, you will use ENVI's interactive Viewshed Tool to calculate the viewshed and reverse viewshed of observer points.
See the following sections:
Files Used in this Tutorial
Tutorial files are available from our ENVI Tutorials web page. Click the Viewshed Analysis link to download the .zip file to your machine, then unzip the files.
|
File |
Description |
|
NEONBoulderDSM.dat
|
Digital surface model (DSM) mosaic of Boulder, Colorado with 1-meter spatial resolution, acquired on 26 June 2013, saved to ENVI raster format 1
|
|
NEONBoulderDSM.hdr
|
Header file for above
|
|
NAIPBoulderAirphoto.dat
|
Aerial image mosaic of Boulder, Colorado from the National Agriculture Imagery Program (NAIP), 1-meter spatial resolution, saved to ENVI raster format 2
|
|
NAIPBoulderAirphoto.hdr
|
Header file for above
|
1 National Ecological Observatory Network. 2014. Data accessed on 24 February 2016. Available on-line at https://data.neonscience.org/home from National Ecological Observatory Network, Boulder, CO, USA.
2 Data available from the U.S. Geological Survey.
Background
Viewshed analysis is the process of identifying areas, or targets which are visible from observer points, whereas reverse viewshed identifies locations from which the observer point can be seen. A gridded elevation product such as DEM, DSM, or DTM provides the elevation values needed to determine visibility relative to the height above the terrain.
This tutorial provides examples using a single observer point, multiple observer points along a path, and multiple observer points within an area.
Start the Viewshed Tool
- From the main menu, select File > Open. Navigate to the \viewshed directory where you saved the downloaded tutorial data. Select the NEONBoulderDSM.dat DSM file and the NAIPBoulderAirphoto.dat raster file, then click OK. The files are added to the Layer Manager and are opened in the view. Leave the NEONBoulderDSM.dat layer above NAIPBoulderAirphoto.dat in the layer stack.
-
In the ENVI Toolbar, click the Viewshed Tool button
. The Viewshed Tool dialog appears with the mode Viewshed (Observers) selected. This mode analyzes what targets an observer point can see.
The Viewshed check box on the right side of the dialog is enabled so ENVI adds a Viewshed layer to the Layer Manager. This is an ROI layer that will show the areas visible from the observer point. The Viewshed layer is not attached to any rasters in the Layer Manager, so you can move it up and down in the layer stack and independently adjust its level of transparency.
Example 1: Examine Visibility from a Single Observer Point
In this example, you will use a single observer point to see how the visibility changes when you move the observer point to different areas in the image.
-
In the image, click on a rooftop. The observer point is added as yellow vertex, and green pixels show the targets the observer point can see.
-
Using the same observer point, select the Reverse Viewshed (Targets) option in the Viewshed Tool dialog. After a few seconds, ENVI processes the reverse viewshed and blue pixels show the areas from which the observer point can be seen.
-
Change the mode back to Viewshed (Observer), then drag the observer point to a road to see how the visibility changes. The observer point is at a lower elevation than when it was on the rooftop, so buildings and other objects are blocking some of the visibility.
-
Click on another rooftop and leave the observer point at this location.
-
In the properties section of the Viewshed Tool dialog, disable the check box for Viewshed to remove it from the Layer Manager and enable the check box for Hidden. The Hidden ROI layer is added to the Layer Manager and shows the areas that are not visible from the observer point. To make the hidden layer easier to see, change the color to red. Click the Hidden color drop down list and select the color.
-
In the Viewshed Tool properties, enable both the Viewshed and the Hidden check boxes. Both layers are now in the Layer Manager, and the view shows the pixels that are visible from the observer point and the pixels that are hidden from the observer point.
- Disable the Hidden layer check box in the Viewshed Tool dialog to remove the layer from the Layer Manager. In the properties of the dialog, the Observer Azimuth value to 180 degrees and reduce the Horizontal FOV to 90 degrees. These settings are useful when the observer point has a fixed orientation and range of view, such as the position of a camera.
-
Click to add an observer point. The observer point is oriented 180 degrees from North, with a horizontal field of view of 90 degrees. Wherever you mark the observer point on the image, it will use these settings.
-
Now return the Observer Azimuth value to 0 degrees. This changes the horizontal orientation of the observer point (facing North), while keeping the horizontal field of view at 90 degrees. Compare the results here with what was visible in the previous step.
-
Finally, return the Horizontal FOV to 360 degrees.
-
To prepare for the next example, right-click the image and select Clear to remove the observer point and viewshed results from the view.
Example 2: Examine Visibility Along a Path
In this example, you will draw a path around the perimeter of a building to analyze the viewshed. You will manually step through the observer points to see the results for each observer point, animate the viewshed results using the player buttons, and save the animation to an MPEG file.
Draw a Path
-
In the Layer Manager, select the NEONBoulderDSM.dat layer and change its transparency to 50% so you can see more details of the NAIPBoulderAirphoto.dat layer beneath it. Zoom in to the view where there are buildings, then right-click and select New > Polyline Path.
-
Mark a polyline around three sides of the perimeter of a building. Click at intervals to go around the building to outline the shape. When you are done, double-click to set it. You should have something resembling this:
- The yellow vertices mark the observer points in the path and are spaced 10 meters apart. The red vertex marks the selected observer point and green pixels show what is visible from that point. Zoom out, if needed, to see more details in the view.
-
Click on a different observer point in the path to see what is visible from it.
-
Press the left or right Arrow key on the keyboard to go forward or backward through each observer point in the path. You can compare the image below with the image above to see how the visibility changed.
- Press and hold the right Arrow key to repeatedly step through the observer points, one at a time. Notice areas have lower visibility than others, due to obstacles such as trees or buildings.
Animate the Viewshed
-
Use animation to step through the path. The player buttons are near the bottom of the Viewshed Tool dialog:
The buttons do the following:
-
Step Backwards through the observer points, one point per click (equivalent to pressing the left Arrow button).
-
Play Backwards animates the observer points in a backward loop, starting with the last point created when the line or shape was drawn and ending with the first point.
-
Pause animation.
-
Play Forwards animates the observer points in a forward loop, starting with the first point created when the line or shape was drawn and ending with the last point.
-
Step Forwards through the observer points, one point per click (equivalent to pressing the right Arrow button).
-
Play Back and Forth animates the observer points in a back-and-forth loop.
-
Save animation saves the animation to an MPEG or GIF file.
- Click the Play Forwards
button to start the animation. The animation steps through the vertices to show the viewshed from each point. If you have multiple paths drawn on the image, the animation will step all the way through the first path that was drawn then step through each successive path that was drawn, in order of creation.
- Click the Pause button
. Animation stops.
- Click the Play Backwards button
. The animation begins in reverse order around the path.
- Click the Pause button
. Animation stops.
- Click the Play Back and Forth button
. The animation plays forwards to then end of the path, then reverses direction to animate backwards through the path.
- Click the Pause button
. Animation stops.
Save the Animation to a Video File
-
Now save the animation to an MPEG file that can be shared with others. Click the Save animation button
. The Save Viewshed Animation to Video dialog appears.
-
Leave the Seconds per location setting at 1. This parameter defines the rate at which to step through each vertex during playback.
-
Save the file to .mp4 format.
-
Enter a path and filename in the Output Filename field.
-
Click OK.
-
In the file manager on your machine, navigate to the saved MPEG file, then double-click to watch the saved animation.
-
In ENVI, right-click and select Reset to clear the image in preparation for the final example.
Example 3: Examine Visibility from an Area
In this example, you will draw filled polygons on two different rooftops to examine what is visible from them.
-
In the Viewshed Tool dialog, change the Observer Range to 150 meters.
Draw Filled Polygon Areas
-
In the image, zoom in to an area of buildings, then right-click and select New > Filled Polygon.

-
Click to mark the shape of a rooftop, then right-click and select Complete and Accept Polygon. The rooftop is marked with yellow vertices spaced 10 meters apart.
-
Now add a second filled polygon. Right-click and select Add > Filled Polygon, then repeat the steps to draw a filled polygon on a rooftop across from the first polygon you drew. You should have two filled polygon areas resembling this:
Animate the Viewshed
Use animation to step through the two areas, as described in the previous example.
Next, you will create a layer of the full viewshed results and create a heatmap that shows what was most visible from the two polygon areas to what was least visible.
Create Full Viewshed Results and Heatmap
- In the Viewshed Tool dialog, ensure the Classification and Heatmap check boxes are enabled, then click the Full Viewshed button. ENVI calculates the result and adds the layers Full Viewshed and Full Viewshed Heatmap to the Layer Manager.
- The Full Viewshed layer overlays the image and displays classes for Out of Range (purple) Full Viewshed (green) and Full Hidden (gray).
-
The Full Viewshed Heatmap layer is below the Full Viewshed layer in the layer stack. You can toggle each layer on or off to hide or show them or move one layer above another to see the results in each. The Full Viewshed Heatmap is a color-coded histogram count of how many times a given pixel was seen. Dark to light blue pixels represent areas seen the least, orange to red pixels represent areas seen the most, and green to yellow pixels represent the areas of moderate visibility.
-
In the Layer Manager, disable the check box for the Full Viewshed layer to see the Full Viewshed Heatmap layer.
-
The colorbar for the heatmap is a separate layer in the Layer Manager. You can toggle the layer on or off, and you can change the color table used in the heatmap. To change the color table that is used, click the Edit Heatmap Color Table button
in the Viewshed Tool dialog.
Save Full Results and Heatmap to Files
Save the results of the Full Viewshed Heatmap and Full Viewshed output to files with the following steps:
- From the Viewshed Tool menu bar, select File > Products > Save "Full Viewshed Heatmap" to File. The Please Select a File for Writing dialog.
- Enter a path and filename, then click Save. The Full Viewshed Heatmap layer name will be replaced with the filename.
- From the Viewshed Tool menu bar, select File > Products > Save "Full Viewshed" to File. The Please Select a File for Writing dialog.
- Enter a path and filename, then click Save. The Full Viewshed layer name will be replaced with the filename.