GDAL_VIEWSHED(1)
π GDAL_VIEWSHED(1) β the GDAL manual, bestie edition
okay so you're reading the GDAL manual page GDAL_VIEWSHED(1) and it's lowkey iconic. buckle up π
β¨ NAME β¨
gdal_viewshed β literally calculates a viewshed raster from an input raster DEM for a user defined point. yes bestie, it's giving "who can see what from where" energy π
πΈ SYNOPSIS πΈ
gdal_viewshed [-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>]
[[-co NAME=VALUE] ...]
[-q] [-om <output mode>]
<src_filename> <dst_filename>
π¦ DESCRIPTION π¦
So by default gdal_viewshed generates a binary visibility raster from one band of the input raster elevation model (DEM). The output raster is of type Byte. And with the -mode flag it can also return a minimum visible height raster of type Float64. two vibes, one tool, we love to see it π
NOTE: the algorithm as implemented currently will only output meaningful results if the georeferencing is in a projected coordinate reference system. fr fr, don't come crying to me about your lat/lon, it's not gonna slay for you π
π OPTIONS π
-co <NAME=VALUE>β okay so many formats have one or more optional creation options that control particulars about the file created. For instance, the GeoTIFF driver supports creation options to control compression, and whether the file should be tiled. iconic of them tbh.
The creation options available vary by format driver, and some simple formats have no creation options at all β not every format is a main character. 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. iykyk π
-b <band>β selects an input band band containing the DEM data. Bands are numbered from1. Only a single band can be used β one band only bestie, sharing is not caring here. Only the part of the raster within the specified maximum distance around the observer point is processed. lowkey efficient β¨-a_nodata <value>β the value to be set for the cells in the output raster that have no data. yes, the "i literally have nothing" cells π«
NOTE: currently, no special processing of input cells at a nodata value is done (which may result in erroneous results). so like... your garbage goes in, your garbage comes out, that's the whole entire vibe check π
-ox <value>β the X position of the observer (in SRS units).-oy <value>β the Y position of the observer (in SRS units). the observer is the main character of this whole operation π-oz <value>β the height of the observer above the DEM surface, in the height unit of the DEM. Default:2. short king representation π-tz <value>β the height of the target above the DEM surface, in the height unit of the DEM. Default:0.-md <value>β maximum distance from observer to compute visibiliy. it is also used to clamp the extent of the output raster. boundaries, bestie, we're setting them π§-cc <value>β coefficient to consider the effect of the curvature and refraction. when calculating visibility between two points (i.e. Line Of Sight or Viewshed), the magnitude of this effect varies with atmospheric conditions and depends on the wavelength. nerd hours but like, in a hot way π§
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). periodt.
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 below (use the Curvature Coeff value for the cc option):
- No Refraction β Refraction Coeff
0, Curvature Coeff1, Sphere Diameter Factor1 - Visible Light β Refraction Coeff
1/7, Curvature Coeff6/7 (=~0.85714), Sphere Diameter Factor7/6 (=~1.1666) - Radio Waves β Refraction Coeff
0.25 ~ 0.325, Curvature Coeff0.75 ~ 0.675, Sphere Diameter Factor1.33 ~ 1.48 - Flat Earth β Refraction Coeff
1, Curvature Coeff0, Sphere Diameter Factorinf. flat earth girlies stay losing π
-iv <value>β pixel value to set for invisible areas. Default:0. the "you literally cannot see this" zones π-ov <value>β pixel value to set for the cells that fall outside of the range specified by the observer location and the maximum distance. Default:0. off the map, out of the group chat βοΈ-vv <value>β pixel value to set for visible areas. Default:255. bestie you're SO visible, ate π-om <output mode>β sets what information the output contains.
Possible values: NORMAL, DEM, GROUND
NORMALreturns a raster of typeBytecontaining visible locations.DEMandGROUNDwill return a raster of typeFloat64containing the minimum target height for target to be visible from the DEM surface or ground level respectively. Flags-tz,-ivand-vvwill be ignored β sorry babe, they're benched for this one.
Default NORMAL
π C API π
Functionality of this utility can be done from C with GDALViewshedGenerate(). if C is your love language, we got you π«Ά
β EXAMPLE β
Compute the visibility of an elevation raster data source with defaults:
[image] A computed visibility for two separate -ox and -oy points on a DEM..UNINDENT
gdal_viewshed -md 500 -ox -10147017 -oy 5108065 source.tif destination.tif
[Wang2000] β Generating Viewsheds without Using Sightlines. Wang, Jianjun, Robinson, Gary J., and White, Kevin. Photogrammetric Engineering and Remote Sensing. p81. https://www.asprs.org/wp-content/uploads/pers/2000journal/january/2000_jan_87-90.pdf π
π AUTHOR π
Tamas Szekeres <szekerest@gmail.com> β an absolute legend, we stan π
π COPYRIGHT π
1998-2026
and that's the whole page, bestie π
β¨ xoxo, sourced from GDAL_VIEWSHED(1) dated Jan 08, 2026 β go touch some DEMs π¦πΈ
π¦ where this page comes from
- epel 9: gdal3.4 3.4.3-5.el9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms