Skip to content

Commit

Permalink
Merge pull request #4416 from rouault/viewshed_change_cc
Browse files Browse the repository at this point in the history
gdal_viewshed: change default value of -cc (curvature coefficient) to 0.85714, standard value for atmospheric refraction (fixes #4415)
  • Loading branch information
rouault authored Sep 2, 2021
2 parents d0f0923 + 4632aa0 commit 364c56b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions autotest/utilities/test_gdal_viewshed.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_gdal_viewshed():
ds = None
gdal.Unlink(viewshed_in)
gdal.Unlink(viewshed_out)
assert cs == 42397
assert cs == 14613
assert nodata is None


Expand All @@ -77,7 +77,7 @@ def test_gdal_viewshed_alternative_modes():
nodata = ds.GetRasterBand(1).GetNoDataValue()
ds = None
gdal.Unlink(viewshed_out)
assert cs == 48478
assert cs == 45734
assert nodata is None

_, err = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdal_viewshed_path() + ' -om GROUND -oz {} -ox {} -oy {} {} {}'.format(oz[0], ox[0], oy[0], viewshed_in, viewshed_out))
Expand All @@ -89,7 +89,7 @@ def test_gdal_viewshed_alternative_modes():
ds = None
gdal.Unlink(viewshed_in)
gdal.Unlink(viewshed_out)
assert cs == 49633
assert cs == 8364
assert nodata is None


Expand All @@ -98,7 +98,7 @@ def test_gdal_viewshed_alternative_modes():

def test_gdal_viewshed_all_options():
make_viewshed_input()
_, err = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdal_viewshed_path() + ' -om NORMAL -f GTiff -oz {} -ox {} -oy {} -b 1 -a_nodata 0 -tz 5 -md 20000 -cc 0.85714 -iv 127 -vv 254 -ov 0 {} {}'.format(oz[1], ox[0], oy[0], viewshed_in, viewshed_out))
_, err = gdaltest.runexternal_out_and_err(test_cli_utilities.get_gdal_viewshed_path() + ' -om NORMAL -f GTiff -oz {} -ox {} -oy {} -b 1 -a_nodata 0 -tz 5 -md 20000 -cc 0 -iv 127 -vv 254 -ov 0 {} {}'.format(oz[1], ox[0], oy[0], viewshed_in, viewshed_out))
assert err is None or err == ''
ds = gdal.Open(viewshed_out)
assert ds
Expand All @@ -107,7 +107,7 @@ def test_gdal_viewshed_all_options():
ds = None
gdal.Unlink(viewshed_in)
gdal.Unlink(viewshed_out)
assert cs == 24390
assert cs == 24435
assert nodata == 0


Expand Down
3 changes: 2 additions & 1 deletion gdal/apps/gdal_viewshed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ MAIN_START(argc, argv)
double dfInvisibleVal = 0.0;
double dfOutOfRangeVal = 0.0;
double dfNoDataVal = -1.0;
double dfCurvCoeff = 0.0;
// Value for standard atmospheric refraction. See doc/source/programs/gdal_viewshed.rst
double dfCurvCoeff = 0.85714;
const char *pszDriverName = nullptr;
const char *pszSrcFilename = nullptr;
const char *pszDstFilename = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions gdal/doc/source/programs/gdal_viewshed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Byte. With the -mode flag can also return a minimum visible height raster of typ
.. option:: -b <band>

Select an input band **band** containing the DEM data. Bands are numbered from 1.
Only a single band can be used. Only the part of the raster within the specified
Only a single band can be used. Only the part of the raster within the specified
maximum distance around the observer point is processed.

.. option:: -a_nodata <value>
Expand Down Expand Up @@ -99,7 +99,7 @@ Byte. With the -mode flag can also return a minimum visible height raster of typ
{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 for CurvCoeff that gdal_viewshed uses is 0.85714 (=~ 1-1/7).
Thus the default value (since GDAL 3.4) for CurvCoeff that gdal_viewshed uses is 0.85714 (=~ 1-1/7).

The height of the DEM is corrected according to the following formula:

Expand Down

0 comments on commit 364c56b

Please sign in to comment.