View source: R/move_and_resize.R
move_and_resize | R Documentation |
Move and resize a simple feature collection of polygons, multipolygons or points.
move_and_resize(x, mask = NULL, xy, prj, k = 1)
x |
an sf POINT, POLYON or MULTIPOLYGON object to resize and move. |
mask |
an sf or sfc POLYGON or MULTIPOLYGON object used to select the area to move an resize. |
xy |
coordinates used to move the inset, bottomleft corner of the inset. |
prj |
CRS string of the output projection of the inset. |
k |
factor used to resize. |
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 == '2030',])
mask <- create_mask(bb = bb, add = TRUE)
inset <- move_and_resize(nc, mask, xy = c(190000, 1000), k = 3)
plot(st_geometry(inset), add = TRUE)
plot(st_geometry(nc))
mask <- st_buffer(st_centroid(st_geometry(nc[nc$CNTY_ID == 2026,])),
dist = 30000)
plot(st_geometry(mask), border = "red", lwd = 2, add = TRUE)
inset <- move_and_resize(nc, mask, xy = c(270000, 5000), k = 2.5)
plot(st_geometry(inset), add = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.