I'm trying to use GDAL Hillshade on SRTM DEM tiles to perform a line-of-sight (LOS) analysis to the sun. The goal is to determine for a given DEM pixel, whether it is in view of the sun or not.

The results I'm getting aren't matching my expectations, so I'm not sure I have a good understanding of hillshade, or if there's a key aspect I'm overlooking.

Current approach (using Python with osgeo GDAL):

  1. Load DEM tile
  2. Run GDAL Hillshade on DEM tile with specific azimuth/altitude angle of sun. Using scale value of 111120 (deg to meters), and zFactor=1.
  3. Binary threshold the hillshade output image (currently at 128 for an 8-bit unsigned output).
  4. Interpret the white (255) pixels as 'visible' to the sun, black (0) pixels as not visible to the sun.

This approach visually looks "valid" when using DEM tiles with large terrain variations (mountain ranges, etc). However, when using DEM tiles in areas without large terrain variations, the majority of the "flat" region comes out a dark grey, which is then thresholded to black.

Admittedly I chose the threshold value of 128 without a good understanding of how the hillshade illumination values are produced. Is there a way to achieve my goal with hillshade, or am I using an entirely invalid approach?



Your Answer

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

Browse other questions tagged or ask your own question.