as.contour,GRaster-method | R Documentation |
Create a GVector
of contour lines from a GRaster
.
## S4 method for signature 'GRaster'
as.contour(x, nlevels, levels)
x |
A |
nlevels |
Numeric: A positive integer or missing (default). Number of levels at which to calculate contours. Levels will be calculated in equal-sized steps from the smallest to the largest value of |
levels |
Numeric vector: A numeric vector of values at which to calculate contour lines. Either |
A GVector
representing contour lines.
terra::as.contour()
, GRASS manual page for module r.contour
(see grassHelp("r.contour")
)
if (grassStarted()) {
# Setup
library(terra)
# Elevation raster
madElev <- fastData("madElev")
# Convert a SpatRaster to a GRaster:
elev <- fast(madElev)
# Calculate contour lines:
conts <- as.contour(elev, nlevels = 10)
plot(elev)
plot(conts, add = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.