binary_stack {prioritizr}R Documentation

Binary stack

Description

Convert a terra::rast() object containing integer/categorical values into a raster object where each layer corresponds to a different integer/categorical value and pixel values denote the presence/absence of the given integer/categorical values.

Usage

binary_stack(x)

## S3 method for class 'Raster'
binary_stack(x)

## S3 method for class 'SpatRaster'
binary_stack(x)

Arguments

x

terra::rast() object with a single layer.

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 rasters as input arguments. It is essentially a wrapper for terra::segregate().

Value

A terra::rast() object.

See Also

category_layer().

Examples

# create raster with categorical values
x <- terra::rast(matrix(c(1, 2, 3, 1, NA, 1), nrow = 3))

# plot the raster
plot(x, main = "x")

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

# plot result
## Not run: 
plot(y)

## End(Not run)

[Package prioritizr version 8.0.4 Index]