marxan_boundary_data_to_matrix: Convert _Marxan_ boundary data to matrix format

View source: R/marxan_boundary_data_to_matrix.R

marxan_boundary_data_to_matrixR Documentation

Convert Marxan boundary data to matrix format

Description

Convert a data.frame object containing Marxan boundary data to matrix format. This function is designed specifically for boundary data (not connectivity data). It ensures that the output matrix correctly specifies symmetric spatial relationships between planning units.

Usage

marxan_boundary_data_to_matrix(x, data)

Arguments

x

problem() object that contains planning unit and zone data to ensure that the argument to data is converted correctly. This argument can be set to NULL if checks are not required (not recommended).

data

data.frame object with the columns "id1", "id2", and "boundary".

Value

A dgCMatrix sparse matrix object.

Notes

In earlier versions, the function could convert boundary data that pertain to multiple zones. This is no longer possible, following updates to streamline the package.

Examples

# create marxan boundary with four planning units and one zone
bldf1 <- expand.grid(id1 = seq_len(4), id2 = seq_len(4))
bldf1$boundary <- 1
bldf1$boundary[bldf1$id1 == bldf1$id2] <- 0.5

# convert to matrix
m1 <- marxan_boundary_data_to_matrix(NULL, bldf1)

# visualize matrix
## Not run: 
image(m1)

## End(Not run)

prioritizr documentation built on Aug. 9, 2023, 1:06 a.m.