You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multidirectional hillshades often look better than the default unidirectional hillshades computed by shade(), but are not natively supported. While they can be created with multiple calls to shade() and combing the output, below is a suggested modification to shade() which accepts multiple values in arguments angle and direction and automatically combines the resulting rasters to multidirectional hillshades:
It offers two options for combining the rasters. I found Reduce to look better when adding a light source almost in zenith (highlights ridgelines nicely, similar to the look of Terrain in Google Maps), and I'm sure the look can be further improved with other angle/direction settings.
Example:
# sample data don't really do justice due to low resolution
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)
hill_multi_mean <- shade(slope, aspect,
angle = c(45, 45, 45, 80),
direction = c(225, 270, 315, 135),
combine = "mean")
hill_multi_reduce <- shade(slope, aspect,
angle = c(45, 45, 45, 80),
direction = c(225, 270, 315, 135),
combine = "Reduce")
plot(hill, col=grey(0:100/100), legend=FALSE, mar=c(2,2,1,4), main = "Default hillshade")
plot(hill_multi_mean, col=grey(0:100/100), legend=FALSE, mar=c(2,2,1,4), main = "Multidirectional hillshade (mean)")
plot(hill_multi_reduce, col=grey(0:100/100), legend=FALSE, mar=c(2,2,1,4), main = "Multidirectional hillshade (Reduce)")
Examples with 30m SRTM, (about 10x10km):
The text was updated successfully, but these errors were encountered:
Thanks, shade is now vectorized for the "angle" and "direction" arguments. I have not added an argument to summarize the output, as that seems easy enough to do in a next step.
library(terra)
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")
h <- shade(slope, aspect, angle = c(45, 45, 45, 80), direction = c(225, 270, 315, 135))
h <- Reduce(mean, h)
Multidirectional hillshades often look better than the default unidirectional hillshades computed by
shade()
, but are not natively supported. While they can be created with multiple calls toshade()
and combing the output, below is a suggested modification toshade()
which accepts multiple values in argumentsangle
anddirection
and automatically combines the resulting rasters to multidirectional hillshades:It offers two options for combining the rasters. I found Reduce to look better when adding a light source almost in zenith (highlights ridgelines nicely, similar to the look of Terrain in Google Maps), and I'm sure the look can be further improved with other angle/direction settings.
Example:
Examples with 30m SRTM, (about 10x10km):
The text was updated successfully, but these errors were encountered: