create_mask: Create a Mask

View source: R/create_mask.R

create_maskR Documentation

Create a Mask

Description

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.

Usage

create_mask(bb, prj, interactive = FALSE, add = FALSE)

Arguments

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.

Value

An sf object is returned.

Examples

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)

riatelab/mapinsetr documentation built on June 15, 2025, 4:29 a.m.