hillshade,GRaster-method | R Documentation |
Hillshade rasters are often used for display purposes because they make topographical relief look "real" to the eye.
## S4 method for signature 'GRaster'
hillshade(x, angle = 45, direction = 0, zscale = 1)
x |
A |
angle |
Numeric: The altitude of the sun above the horizon in degrees. Valid values are in the range [0, 90], and the default value is 45 (half way from the horizon to overhead). |
direction |
The direction (azimuth) in which the sun is shining in degrees. Valid values are in the range 0 to 360. The default is 0, meaning the sun is at due south (180 degrees) and shining due north (0 degrees). Note that in this function, 0 corresponds to north and 180 to south, but in the GRASS module |
zscale |
Numeric: Value by which to exaggerate terrain. The default is 1. Numbers greater than this will increase apparent relief, and less than this (even negative) will diminish it. |
A GRaster
.
if (grassStarted()) {
# Setup
library(terra)
# Example data
madElev <- fastData("madElev")
# Convert a SpatRaster to a GRaster
elev <- fast(madElev)
# Calculate all topographic metrics
topos <- terrain(elev, v = "*")
topos
plot(topos) # NB Aspect has values of NA when it cannot be defined
# Calculate a hillshade raster
hs <- hillshade(elev)
plot(hs)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.