This function calculates boundary length data. Be aware that this function is designed with performance in mind, and as a consequence, if this function is used improperly then it may crash R. Furthermore, multipart polygons with touching edges will likely result in inaccuracies.

calcBoundaryData(x, tol, length.factor, edge.factor)

# S3 method for PolySet
calcBoundaryData(x, tol = 0.001, length.factor = 1, edge.factor = 1)

# S3 method for SpatialPolygons
calcBoundaryData(x, tol = 0.001, length.factor = 1, edge.factor = 1)

# S3 method for sf
calcBoundaryData(x, tol = 0.001, length.factor = 1, edge.factor = 1)

Arguments

x

sf::st_sf() or PBSMapping::PolySet object.

tol

numeric to specify precision of calculations. In other words, how far apart vertices have to be to be considered different?

length.factor

numeric to scale boundary lengths.

edge.factor

numeric to scale boundary lengths for edges that do not have any neighbors, such as those that occur along the margins.

Value

A data.frame with 'id1' (integer), 'id2' (integer), and 'amount' (numeric) columns.

See also

This function is based on the algorithm in QMARXAN https://github.com/tsw-apropos/qmarxan for calculating boundary length.

Examples

# \dontrun{
# simulate planning units
sim_pus <- sim.pus(225L)

# calculate boundary data
bound.dat <- calcBoundaryData(sim_pus)

# print summary of boundary data
summary(bound.dat)
#>       id1              id2            boundary    
#>  Min.   :  1.00   Min.   :  1.00   Min.   :1.000  
#>  1st Qu.: 59.75   1st Qu.: 51.75   1st Qu.:1.000  
#>  Median :117.00   Median :109.00   Median :1.000  
#>  Mean   :116.53   Mean   :109.47   Mean   :1.008  
#>  3rd Qu.:174.25   3rd Qu.:166.25   3rd Qu.:1.000  
#>  Max.   :225.00   Max.   :225.00   Max.   :2.000  
# }