create_mask | R Documentation |
Create a mask based on a bounding box (bbox
), a simple
feature collection (sf
) extent, a simple feature geometry list column
(sfc
) extent or an interactively defined rectancle.
create_mask(bb, prj, interactive = FALSE, add = FALSE)
bb |
either a bounding box, a numeric vector (xmin, ymin, xmax, ymax), an sf or sfc object. |
prj |
a CRS string. |
interactive |
define the mask interactively. |
add |
add the mask to the current plot. |
An sf object is returned.
library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
nc <- st_transform(nc, 32119)
plot(st_geometry(nc))
bb <- st_bbox(nc[nc$CNTY_ID %in% c('2030', '1989', '1938'),])
mask <- create_mask(bb = bb, add = TRUE)
plot(st_geometry(nc))
bb <- nc[nc$CNTY_ID %in% c('2030', '1989', '1938'),]
mask <- create_mask(bb = bb, add = TRUE)
plot(st_geometry(nc))
bb <- c(589912, 159757, 694332, 257053)
mask <- create_mask(bb = bb, prj=32119, add = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.