2

I've been experimenting with running Viewshed analysis in GDAL (Using Command Line Interface). And I'm able to run it more or less accurately, however, no matter what value I enter for "-md" the resulting viewshed raster is always the same size as the DEM used. I've tried a couple different DEMs and keep getting the same issue.

This is the code I've used

gdal_viewshed -ox -152.55862 -oy 57.754465 -oz 200 -tz 1.0 -md 5000.0 -f GTiff -cc 0.85714 kodiakdemwarp12032024.tiff outputtest5.tiff

I've tried this with multiple -md values ranging from 100 to 10000 and the appearance of the output geotiff is identical regardless.

Source DEMs and output file can be found here

2
  • 2
    Maybe your data are in EPSG:4326 and maybe -md is using the units of the coordinate system? Then 100 degrees means about 10000 kilometers, and 1000 degrees makes two and a half rounds around the world. But I am only guessing.
    – user30184
    Commented Dec 3 at 21:33
  • 1
    That makes sense, I tried it again using .1 as a value and it returned a more sensible raster. I'll experiment and comment back
    – Jeremy
    Commented Dec 3 at 21:36

1 Answer 1

1

The gdal_viewshed documentation specifically notes:

The algorithm as implemented currently will only output meaningful results if the georeferencing is in a projected coordinate reference system.

Your kodiakdemwarp12032024.tiff is not projected, it's in EPSG:4326 which is a geographic coordinate system and uses decimal degrees as the horizontal units, not meters or feet which is why your -md value was way too big.

So use kodiakdem12032024.tiff instead, which is in EPSG:3413, a projected coordinate system. You'll need to project your observer coordinates to that CRS as well.

$ echo 57.754465 -152.55862 | cs2cs EPSG:4326 EPSG:3413  # note lat, lon order because EPSG:4326
-3417553.77 1081395.95
$ gdal_viewshed -ox -3417553.77 -oy 1081395.95 -oz 200 -tz 1.0 -md 5000.0 -f GTiff -cc 0.85714 kodiakdem12032024.tiff output.tif

Output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.