[GIS] Extract shadows from a DEM using GrassGIS’s r.sunmask command

demgrassshadow

I'm trying to use GrassGIS to extract the shadow from a DEM (elevation data).

The DEM I'm using shows Geneva (plus a part of the Alps mountains), and was captured by the SRTM. The elevation data was downloaded from the USGS website, and was already projected to the WGS84 coordinate system:

srtm

The command I've used in GrassGIS to calculate the shadow is r.sunmask, for which the date, time, and timezone has to be provided:

r.sunmask elevation=n46_e006_1arc_v3@PERMANENT output=alps-sunmask.tif year=2014 month=9 day=23 hour=11 minute=0 timezone=1

The problem is that the image produced with r.sunmask is completely empty. Is something wrong with the command above?

P.S: I've checked the answer suggested here, but I'm unable to make r.sun work since I can't find which parameter correspond to the output.

Best Answer

You need x, y and z units in meters. Or at least, consistent units. If your raster is in WGS84 and elevations are in meters, they're not consistent. This can give weird results for a lot of algorithms.

If the units aren't consistent, the mountains are thousands of times steeper than you think they are - nearly vertical - and almost everything is in shadow... that would explain things if your raster is mostly or all values of 1

I picked a small area in the Swiss Alps from SRTM and used warp to convert it to epsg:21781 (using Cubic interpolation to avoid 'artifacts').

Then used r.sunmask.datetime . This example was 23rd September but I chose 9am to give more obvious shadows.

In my case I used it via processing/QGIS, which insists on easting/northings. Those two parameters should be optional, so I manually chose a point near the centre, using the coordinate capture plugin. If you're using this from the GRASS command line you don't need to do that.

EDIT note that if doing this outside of qgis/processing, you'll need to remember to set the region using g.region

Here's the result... enter image description here

And with the same settings, but done as WGS84 - almost everything in shadow

enter image description here

Related Question