Learn R Programming

terra (version 1.8-80)

boundaries: Detect boundaries (edges)

Description

Detect boundaries (edges). Boundaries are cells that have more than one class in the 4 or 8 cells surrounding it, or, if classes=FALSE, cells with values and cells with NA.

Usage

# S4 method for SpatRaster
boundaries(x, classes=FALSE, inner=TRUE, 
         directions=8, falseval=0, filename="", ...)

Arguments

Value

SpatRaster. Cell values are either 1 (a border) or 0 (not a border), or NA

See Also

focal, patches

Examples

Run this code
r <- rast(nrows=18, ncols=36, xmin=0)
r[150:250] <- 1
r[251:450] <- 2
bi <- boundaries(r)
bo <- boundaries(r, inner=FALSE)
bc <- boundaries(r, classes=TRUE)
#plot(bc)

Run the code above in your browser using DataLab