# NOT RUN {
# load data
data(sim_pu_raster, sim_pu_polygons)
# subset data to reduce processing time
r <- crop(sim_pu_raster, c(0, 0.3, 0, 0.3))
ply <- sim_pu_polygons[c(1:2, 10:12, 20:22), ]
# create boundary matrix using raster data
bm_raster <- boundary_matrix(r)
# create boundary matrix using polygon data
bm_ply1 <- boundary_matrix(ply)
# create boundary matrix using polygon data and GEOS STR query trees
# to speed up processing
bm_ply2 <- boundary_matrix(ply, TRUE)
# plot raster and boundary matrix
# }
# NOT RUN {
par(mfrow = c(1, 2))
plot(r, main = "raster", axes = FALSE, box = FALSE)
plot(raster(as.matrix(bm_raster)), main = "boundary matrix",
axes = FALSE, box = FALSE)
# }
# NOT RUN {
# plot polygons and boundary matrices
# }
# NOT RUN {
par(mfrow = c(1, 3))
plot(r, main = "polygons", axes = FALSE, box = FALSE)
plot(raster(as.matrix(bm_ply1)), main = "boundary matrix", axes = FALSE,
box = FALSE)
plot(raster(as.matrix(bm_ply2)), main = "boundary matrix (STR)",
axes = FALSE, box = FALSE)
# }
Run the code above in your browser using DataLab