Sunday, 11 August 2019

Viewshed Analysis With GDAL


I am looking to perform a simple (one observer location) viewshed analysis on a standard DEM using GDAL (either python or .NET bindings).


I have searched, but haven't found any readily available implementation. Can anyone point me in the right direction?



Answer



I've used python scripts to run both the r.los and r.viewshed grass commands that Peter mentioned.


The advantage with r.los is that it works straight out-of-the-box with grass6, but is slightly slower to run over large raster DEMs. r.viewshed is a bit of a pain to get running, but is a vast speed improvement on very large rasters. See if the times for your DEM are acceptable using r.los, then give r.viewshed a go if it's taking too long. Here's a quick python example using grass64 r.viewshed, but you'll need to get the python grass bindings working first (see http://grass.osgeo.org/wiki/GRASS_and_Python).


import grass.script as grass


grass.run_command('r.viewshed',
input='standard.dem',
output='viewshed',
coordinate=[observer_x, observer_y],
obs_elev=1.75,
tgt_elev=0.0,
memory=4098,
overwrite=True,
quiet=True

)

with a better description of the parameters available at http://grass.osgeo.org/gdp/html_grass70/r.viewshed.html


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...