shade | R Documentation |
Compute hill shade from slope and aspect layers (both in radians). Slope and aspect can be computed with function terrain
.
A hill shade layer is often used as a backdrop on top of which another, semi-transparent, layer is drawn.
shade(slope, aspect, angle=45, direction=0, normalize=FALSE,
filename="", overwrite=FALSE, ...)
slope |
SpatRasterwith slope values (in radians) |
aspect |
SpatRaster with aspect values (in radians) |
angle |
The elevation angle(s) of the light source (sun), in degrees |
direction |
The direction (azimuth) angle(s) of the light source (sun), in degrees |
normalize |
Logical. If |
filename |
character. Output filename |
overwrite |
logical. If |
... |
additional arguments for writing files as in |
Horn, B.K.P., 1981. Hill shading and the reflectance map. Proceedings of the IEEE 69(1):14-47
terrain
f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
alt <- disagg(r, 10, method="bilinear")
slope <- terrain(alt, "slope", unit="radians")
aspect <- terrain(alt, "aspect", unit="radians")
hill <- shade(slope, aspect, 40, 270)
plot(hill, col=grey(0:100/100), legend=FALSE, mar=c(2,2,1,4))
plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)
# A better hill shade may be achieved by combining
# different angles and directions. For example
h <- shade(slope, aspect, angle = c(45, 45, 45, 80), direction = c(225, 270, 315, 135))
h <- Reduce(mean, h)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.