Learn R Programming

landscapemetrics (version 1.1)

get_boundaries: get_boundaries

Description

Get boundary cells of patches

Usage

get_boundaries(landscape, directions, as_NA, return_raster)

# S3 method for RasterLayer get_boundaries(landscape, directions = 4, as_NA = FALSE, return_raster = TRUE)

# S3 method for RasterStack get_boundaries(landscape, directions = 4, as_NA = FALSE, return_raster = TRUE)

# S3 method for RasterBrick get_boundaries(landscape, directions = 4, as_NA = FALSE, return_raster = TRUE)

# S3 method for stars get_boundaries(landscape, directions = 4, as_NA = FALSE, return_raster = TRUE)

# S3 method for list get_boundaries(landscape, directions = 4, as_NA = FALSE, return_raster = TRUE)

# S3 method for matrix get_boundaries(landscape, directions = 4, as_NA = FALSE, return_raster = TRUE)

Arguments

landscape

RasterLayer or matrix.

directions

Rook's case (4 neighbours) or queen's case (8 neighbours) should be used as neighbourhood rule

as_NA

If true, non-boundary cells area labeld NA

return_raster

If false, matrix is returned

Value

RasterLayer or matrix

Details

All boundary/edge cells are labeled 1, all non-boundary cells 0. NA values are not changed. Boundary cells are defined as cells that neighbour either a NA cell or a cell with a different value than itself. Non-boundary cells only neighbour cells with the same value than themself.

Examples

Run this code
# NOT RUN {
class_1 <- get_patches(landscape, class = 1)[[1]]

get_boundaries(class_1)
get_boundaries(class_1, return_raster = FALSE)

class_1_matrix <- raster::as.matrix(class_1)
get_boundaries(class_1_matrix, return_raster = FALSE)

# }

Run the code above in your browser using DataLab