Convert Marxan boundary data to matrix format
Source:R/marxan_boundary_data_to_matrix.R
marxan_boundary_data_to_matrix.Rd
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.
Arguments
- x
problem()
object that contains planning unit and zone data to ensure that the argument todata
is converted correctly. This argument can be set toNULL
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
# \dontrun{
image(m1)
# }