Description Usage Arguments Details Value Examples
Generate a boundary matrix describing the shared and exposed edges of planning units.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | boundary_matrix(x, ...)
## S3 method for class 'Raster'
boundary_matrix(x, ...)
## S3 method for class 'SpatialPolygons'
boundary_matrix(x, ...)
## S3 method for class 'SpatialLines'
boundary_matrix(x, ...)
## S3 method for class 'SpatialPoints'
boundary_matrix(x, ...)
## S3 method for class 'data.frame'
boundary_matrix(x, ...)
|
x |
|
... |
not used. |
This function returns a dsCMatrix-class
symmetric sparse matrix. Cells on the off-diagonal indicate the length of
the shared boundary between two different planning units. Cells on the
diagonal indicate length of a given planning unit"s edges that have no
neighbors (eg. for edges of planning units found along the
coastline). This function assumes the data are in a coordinate
system where Euclidean distances accurately describe the proximity
between two points on the earth. Thus spatial data in a longitude/latitude
coordinate system (aka WGS84)
should be reprojected to another coordinate system before using this
function.
Matrix{dsCMatrix-class}
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ## load data
data(sim_pu_raster, sim_pu_polygons)
## create boundary matrix using raster data
# crop raster to 9 cells
r <- crop(sim_pu_raster, c(0, 0.3, 0, 0.3))
# make boundary matrix
bm_raster <- boundary_matrix(r)
## create boundary matrix using polygon data
# subset 9 polygons
ply <- sim_pu_polygons[c(1:2, 10:12, 20:22), ]
# make boundary matrix
bm_ply <- boundary_matrix(ply)
# plot raster and connected matrix
par(mfrow=c(1, 2))
plot(r, main = "raster")
plot(raster(as.matrix(bm_raster)), main = "boundary matrix")
# plot polygons and connected matrix
par(mfrow=c(1, 2))
plot(r, main = "polygons")
plot(raster(as.matrix(bm_ply)), main = "boundary matrix")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.