GDAL_VIEWSHED(1) | GDAL | GDAL_VIEWSHED(1) |
gdal_viewshed - Calculates a viewshed raster from an input raster DEM for a user defined point
gdal_viewshed [--help] [--help-general] [-b <band>] [-a_nodata <value>] [-f <formatname>] [-oz <observer_height>] [-tz <target_height>] [-md <max_distance>] -ox <observer_x> -oy <observer_y> [-vv <visibility>] [-iv <invisibility>] [-ov <out_of_range>] [-cc <curvature_coef>] [-os <observer_spacing>] [-j <relative job count>] [-co <NAME>=<VALUE>]... [-q] [-om <output mode>] <src_filename> <dst_filename>
By default the gdal_viewshed generates a binary visibility raster from one band of the input raster elevation model (DEM). The output raster will be of type Byte. With the -mode flag can also return a minimum visible height raster of type Float64.
NOTE:
The creation options available vary by format driver, and some simple formats have no creation options at all. A list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. See Raster drivers format specific documentation for legal creation options for each format.
NOTE:
Different applications for calculating visibility use different interchangeable notation to describe this phenomena: Refraction Coefficient, Curvature Coefficient, and Sphere Diameter Factor. gdal_viewshed uses the Curvature Coefficient notation.
{CurvCoeff}=1-{RefractionCoeff}
Changes in air density curve the light downward causing an observer to see further and the earth to appear less curved, as if the sphere (earth) diameter is larger then it actually is. The ratio between that imaginary sphere diameter and the actual sphere diameter is given by the formula:
{SphereDiameterFactor}=1/{CurvCoeff}=1/(1-{RefractionCoeff})
For visible light, the standard atmospheric refraction coefficient that is generally used is 1/7. Thus the default value (since GDAL 3.4) for CurvCoeff that gdal_viewshed uses is 0.85714 (=~ 1-1/7) for Earth CRS. Starting with GDAL 3.6, for non-Earth CRS (those whole semi-major axis differs by more than 5% with the one of WGS 84), CurvCoeff default value is 1.0, to account for the no refraction use case.
The height of the DEM is corrected according to the following formula:
Height_{Corrected}=Height_{DEM}-{CurvCoeff}\frac{{TargetDistance}^2}{SphereDiameter}
Typical coefficient values are given in the table below (use Curvature Coeff value for the cc option)
Use Case | Refraction Coeff | Curvature Coeff | Sphere Diameter Factor |
No Refraction | 0 | 1 | 1 |
Visible Light | 1/7 | 6/7 (=~0.85714) | 7/6 (=~1.1666) |
Radio Waves | 0.25 ~ 0.325 | 0.75 ~ 0.675 | 1.33 ~ 1.48 |
Flat Earth | 1 | 0 | inf |
Possible values: NORMAL, DEM, GROUND, ACCUM
NORMAL returns a raster of type Byte containing visible locations.
DEM and GROUND will return a raster of type Float64 containing the minimum target height for target to be visible from the DEM surface or ground level respectively. Flags -tz, -iv and -vv will be ignored.
Cumulative (ACCUM) mode will create an eight bit raster the same size as the input raster where each cell represents the relative observability from a grid of observer points. See the -os option.
Default NORMAL
Functionality of this utility can be done from C with GDALViewshedGenerate().
Screenshot of 2 combined viewshed analysis, with the yellow pixels showing the area that is visible from the both observation locations (the green dots), while the small green area is only visible from one location.
Create a viewshed raster with a radius of 500 for a person standing at location (-10147017, 5108065).
gdal_viewshed -md 500 -ox -10147017 -oy 5108065 source.tif destination.tif
Tamas Szekeres <szekerest@gmail.com>
1998-2025
January 8, 2025 |