terrain,GRaster-method | R Documentation |
terrain()
calculates topographic indices, including slope, aspect, curvature, and partial slopes (slopes in the east-west or north-south directions).
## S4 method for signature 'GRaster'
terrain(
x,
v = "slope",
units = "degrees",
undefinedAspect = NA,
northIs0 = TRUE
)
x |
A |
v |
Name of the topographic metric(s) to calculate. Valid values include one or more of:
|
units |
Character: "Units" in which to calculate slope and aspect: either |
undefinedAspect |
Numeric or |
northIs0 |
Logical: If |
A GRaster
with one or more layers.
terra::terrain()
, ruggedness()
, wetness()
, geomorphons()
, module r.slope.aspect
in GRASS
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.