Learn R Programming

prioritizr (version 4.1.5)

binary_stack: Binary stack

Description

Convert a RasterLayer-class object containing categorical identifiers into a RasterStack-class object where each layer corresponds to a different identifier and values indicate the presence/absence of that category in the input object.

Usage

binary_stack(x)

Arguments

x

Raster-class object containing a single layer.

Value

RasterStack-class object.

Details

This function is provided to help manage data that encompass multiple management zones. For instance, this function may be helpful for preparing raster data for add_locked_in_constraints and add_locked_out_constraints since they require binary RasterStack-class objects as input arguments.

See Also

category_layer.

Examples

Run this code
# NOT RUN {
# create raster with categorical identifers
x <- raster(matrix(c(1, 2, 3, 1, NA, 1), nrow = 3))

# convert to binary stack
y <- binary_stack(x)

# plot categorical raster and binary stack representation
# }
# NOT RUN {
plot(stack(x, y), main = c("x", "y[[1]]", "y[[2]]", "y[[3]]"), nr = 1)
# }

Run the code above in your browser using DataLab