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.

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

Examples

# 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 plot(stack(x, y), main = c("x", "y[[1]]", "y[[2]]", "y[[3]]"), nr = 1)