r.sunmask(1)

✨ r.sunmask ✨ β€” the cast-shadow calculator bestie πŸ’…

okay so this is the page for r.sunmask from the GRASS GIS User's Manual, and honestly? it's giving main character energy. it figures out which bits of your terrain are sitting in shadow, based on where the sun is and how tall your hills are. you either tell it exactly where the sun is (option A), or you hand it a date and time and it does the math itself (option B). either way, slay.

KEYWORDS: raster, solar, sun position, shadow 🌞


🌈 SYNOPSIS

r.sunmask
r.sunmask --help
r.sunmask [-zsg] elevation=name  [output=name]   [altitude=float]
[azimuth=float]   [year=integer]   [month=integer]   [day=integer]
[hour=integer]   [minute=integer]   [second=integer]
[timezone=integer]   [east=value]   [north=value]   [--overwrite]
[--help]  [--verbose]  [--quiet]  [--ui]

πŸŽ€ Flags

  • -z β€” do not ignore zero elevation. like, respect the zeros, they're valid 🫢
  • -s β€” just calculate the sun position and dip. no map, no drama, output only ✨
  • -g β€” print the sun position output in shell script style (this one is iconic for eval(), iykyk)
  • --overwrite β€” let output files overwrite existing files (permission to be feral πŸ’€)
  • --help β€” print usage summary
  • --verbose β€” verbose module output
  • --quiet β€” quiet module output
  • --ui β€” force launching GUI dialog

πŸ¦‹ Parameters

  • elevation=name β€” [required] name of input elevation raster map. non-negotiable bestie
  • output=name β€” name for output raster map
  • altitude=float β€” altitude of the sun in degrees above the horizon (that's mode A). Options: 0-89.999
  • azimuth=float β€” azimuth of the sun in degrees from north (also mode A). Options: 0-360
  • year=integer β€” year (mode B). Options: 1950-2050
  • month=integer β€” month (mode B). Options: 0-12
  • day=integer β€” day (mode B). Options: 0-31
  • hour=integer β€” hour (mode B). Options: 0-24
  • minute=integer β€” minutes (mode B). Options: 0-60
  • second=integer β€” seconds (mode B). Options: 0-60. Default: 0
  • timezone=integer β€” timezone. east positive, offset from GMT, and you also use this to adjust for daylight savings πŸ‘‘
  • east=value β€” easting coordinate (point of interest). Default: map center
  • north=value β€” northing coordinate (point of interest). Default: map center

πŸ’– DESCRIPTION

so basically, r.sunmask creates an output map layer based on an input elevation raster map layer plus the position of the sun. that output layer contains the cast shadow areas resulting from sunlight and elevation. you can either give it the sun position directly, or let the module calculate it from the location and date/time parameters you feed it, using the SOLPOS (Solar and Moon Position Algorithm) developed by the National Renewable Energy Laboratory (NREL). SOLPOS runs in two modes, and you must pick one:

  • (A) parameters to specify the exact known position of the sun, or
  • (B) parameters to specify the date/time for the sun position calculation by r.sunmask itself

the module also does sunset/sunrise checks and refraction correction for the sun position calculation. local coordinate systems get internally transformed to latitude/longitude for the SOLPOS algorithm. ngl, elevation is not taken into account for those sunset/sunrise calculations.

the solar zenith angle (aka the "sun angle above horizon") is defined as the angle between the horizon and the vertical (directly overhead, i.e. zenith). its values range from 90° when the sun is directly overhead, down to 0° when the sun is on the horizon. values lower than 0° mean the sun is below the horizon. 😭

the solar azimuth angle (aka "sun azimuth") defines the direction of the sun. it's the angle between north and the projection of the sun's rays onto the horizontal plane. this angle is measured in a clockwise direction and can vary between 0° and 360°. specifically: azimuth 0° means the sun is in the north, 90° in the east, 180° in the south and 270° in the west. periodt. 🧭


πŸ“ NOTES

r.sunmask and daylight saving time: instead of converting the local time to GMT, the SOLPOS algorithm uses what's known as Local Standard Time, which is generally defined as an offset from GMT. so the key is the offset from GMT, which is the solpos Time Zone parameter. if you specify clock time (different for winter and summer), you'd have to change the Time Zone parameter in r.sunmask (the timezone parameter) seasonally. see also Daylight saving time by region and country.

Note: in latitude/longitude projects, the position coordinates pair (east/west) has to be specified in decimal degree (not DD:MM:SS). if it's not specified, the map center's coordinates will be used. also g.region -l displays the map center's coordinates in latitude/longitude (or g.region -c in the actual coordinate system).

Note for module usage with the -g flag, when performing calculations close to sunset/sunrise:

 [...]
 sunangleabovehorizont=0.434240
 sunrise=07:59:19
 sunset=16:25:17
 Time (07:59:02) is before sunrise (07:59:19)!
 WARNING: Nothing to calculate. Please verify settings.
 No map calculation requested. Finished.

in the calculation above it looks like a mistake, because the program says we're before sunrise while the sun angle above horizon is already positive. the reason is that the sun angle above horizon is calculated with correction for atmosphere refraction, while sunrise and sunset are calculated without correction for atmosphere refraction. the output without the -g flag contains related indications. no cap, that's just how it is πŸ™ˆ


🌸 EXAMPLE

example for North Carolina sample data set for the calculation of sun position angles and more:

# set the region to a place near Raleigh (NC)
g.region raster=elev_lid792_1m -p
# compute only sun position and no output map
r.sunmask -s elev_lid792_1m year=2012 month=2 \
          day=22 hour=10 minute=30 timezone=-5
Using map center coordinates: 638650.000000 220375.000000
Calculating sun position... (using solpos (V. 11 April 2001) from NREL)
2012/02/22, daynum: 53, time: 10:30:00 (decimal time: 10.500000)
long: -78.678856, lat: 35.736160, timezone: -5.000000
Solar position: sun azimuth: 143.006409, sun angle above horz. (refraction corrected): 36.233879
Sunrise time (without refraction): 06:58:11
Sunset time  (without refraction): 17:58:47
# with -g flag, useful for eval() shell function
r.sunmask -s -g elev_lid792_1m  year=2012 month=2 \
          day=22 hour=10 minute=30 timezone=-5
Using map center coordinates: 638650.000000 220375.000000
Calculating sun position... (using solpos (V. 11 April 2001) from NREL)
date=2012/02/22
daynum=53
time=10:30:00
decimaltime=10.500000
longitudine=-78.678856
latitude=35.736160
timezone=-5.000000
sunazimuth=143.006409
sunangleabovehorizon=36.233879
sunrise=06:58:11
sunset=17:58:47

πŸ™Œ Acknowledgements

Acknowledgements: National Renewable Energy Laboratory for their SOLPOS 2.0 sun position algorithm. absolute icons, ty for your service 🫢


πŸ‘€ SEE ALSO

g.region, r.sun, r.sunhours, r.slope.aspect


πŸ‘‘ AUTHORS

  • Janne Soimasuo, Finland, 1994
  • update to FP by Huidae Cho, 2001
  • SOLPOS algorithm feature added by Markus Neteler, 2001

πŸ’» SOURCE CODE

available at: r.sunmask source code (history)

accessed: Saturday Jan 17 05:41:01 2026

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index


and that's the whole page bestie!! πŸ’–βœ¨ this was GRASS GIS 8.4.2 Reference Manual energy, Β© 2003-2025 GRASS Development Team, and the version floating around at the bottom of the original was GRASS 8.4.2, dated Saturday Jan 17 05:41:01 2026. go cast some shadows, you got this πŸŒˆπŸ‘‘πŸ’…

πŸ“¦ where this page comes from