as.contour: Contour lines from a "GRaster"

as.contour,GRaster-methodR Documentation

Contour lines from a "GRaster"

Description

Create a GVector of contour lines from a GRaster.

Usage

## S4 method for signature 'GRaster'
as.contour(x, nlevels, levels)

Arguments

x

A GRaster.

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 x. Either nlevels or levels must be specified.

levels

Numeric vector: A numeric vector of values at which to calculate contour lines. Either nlevels or levels must be specified.

See Also

terra::as.contour(), module r.contour in GRASS

Examples

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(madElev)
plot(conts, add = TRUE)

}

adamlilith/fasterRaster documentation built on Sept. 23, 2024, 1:28 a.m.