# How to create hillshade models every hour for a zone with GDAL

I´m trying to calculate the hillshade models from a zone for every hour during one month. I´m using the GDAL, gdaldem hillshade (I don´t know if there is another tool/library).

The problem is how to model the different situations during a day from the time and not from the elevation and azimuth of the sun. I would like use the time to generate the hillshade model for this time, so the modelling of my surface uses the different situations of elevation and azimuth for this time for my zone.

If I understood it the elevation and azimuth parameters describe the sun's position. So for the same elevation /azimuth parameters the hillshades describe the shadows for different times (for example: the situation of the sun as "elevation 1.79 and azimuth 121" describes the shadows for a part of my zone for 01:00:00 pm and for another part for 01:30:00 pm).

Is it possible to generate hillshade models describing the shadows in a moment for a zone?

As a guide on how to start:

• This is a paper describing the Sun Position Algorithm, and this is a python module implementing the SPA for pretty much everything that you could do with it, including the calculation of the sun's position at any given time/location. There is complete GDAL support for Python (see e.g. here and here). I'm sure there is something similar in R...
Another way could be to use PyQGIS from within QGIS and run a script with any hillshading tool that is supported (e.g. SAGA and GRASS).

• Since you mentioned GRASS in your tags; there is the r.sun... function family that can be used to either calculate the suns position and/or calculate a shadow map for any time/position via different output files:
r.sun.hourly - let´s you define a time span and runs r.sun for each hour on your DEM. see r.sun -> 'Extraction of shadow maps', you can use these as overlay for your DEM to get similar results as hillshading.
r.sunmask - calculates a shadowmap for any time/date for your DEM, similar use as above. You will however have to batch process each hour via shellscript if you want to automate this.

Possibly the easiest solution to use the GRASS tools would again be to script this within PyQGIS in QGIS, since GRASS tools are available there.

Hope that helps (I'm looking forward for any quicker solution that I didn´t think of, or a dedicated tool even).

• This seems to address some of the issues in the original question. However, I thought a main point of the question is around modeling a spatially-varying hillshade. If the input file covers the entire continental United States, using an elevation and "azimuth" (in the raster space) for the sun position has the west coast and east coast are being rendered at the same local time, which is bad. If the sun position is for ~morning west coast then it should be ~noon east coast. But processing the entire raster at once doesn't represent the spatial differences in sun position that occur in reality. Jan 23 '18 at 22:34
• So interesting both answers. If you let me I' ll response above comments together. Firstly ThingumaBob describes several technical solutions, when I explore them I'll tell you if they works. Then Logan Byers understood rigthly my question: it is imposible describe the hillshades of a big zone using only an elevation and azimuth parameters, so if my input parameter is a time (for example 06 UTC) we'll have for each "pixel" of my dem raster different elevation/azimuth values at 6 h. Sincerely I don't know if the ThingumaBob's response will resolve this question. I'll try it and I'll comment it. Jan 23 '18 at 23:46
• @LoganByers no. what I suggested does indeed mainly adress the temporal variety for one dataset, it does not take the geoidal bending into account. I'm not sure what GRASS does with a continental wide DEM, but I doubt it will compute a realistic shadow model. Jan 24 '18 at 8:09
• @Acicate maybe a tiled aporoach could get closer to that (the SPA does return null as elevation if the sun's not up), if proper scripted? otherwise I guess you'd need true 3D rendered raycasting on a spherical body with your DEM applied as heightmap, e.g. a globe modeled in OpenGL or WebGL. I use Three.js a lot, it's possible there, albeit somewhat intensive to implement. also, you are stuck with a 3D scene then, with some trouble to get a planar representation in the sense of a hillshade map from there... Jan 24 '18 at 8:13