m_r | R Documentation |
do stuff, all layers must use a cartographic projection, no lon/lat.
m_r(x, mask, y, return_k = FALSE)
x |
the layer to cut, resize and move, sf |
mask |
the targeted area in x, sf or sfc |
y |
destination, sf or sfc |
return_k |
return the k factor |
a layer
library(sf)
library(mapsf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
# Ne fonctionne qu'avec 2 fonds projetés
nc <- st_transform(nc, 32119)
# Créer des boites
y <- st_as_sfc(st_bbox(
c(xmin = 270000, ymin = 00000,
xmax = 550000, ymax = 100000),
crs = 32119))
y <- st_make_grid(y, n = c(3,2))
mf_map(nc)
mf_map(y, add = TRUE)
# plusieurs objets agrandis
inset1 <- m_r(x = nc, mask = nc[1,], y = y[1])
mf_map(nc[1, ], col = 2, add = TRUE)
mf_map(inset1, col = 2, add = TRUE)
# plusieurs objets agrandis
inset2 <- m_r(x = nc, mask = nc[2,], y = y[2])
mf_map(nc[2, ], col = 3, add = TRUE)
mf_map(inset2, col = 3, add = TRUE)
# un seul objet, réduit
inset3 <- m_r(x = nc[nc$CNTY_ID == 2000, ],
mask = nc[nc$CNTY_ID == 2000, ],
y = y[3])
mf_map(nc[nc$CNTY_ID == 2000, ], col = 4, add = TRUE)
mf_map(inset3, col = 4, add = TRUE)
# plusieurs objets dans une autre proj
mtq <- mf_get_mtq()
inset4 <- m_r(x = mtq, mask = mtq, y = y[4])
mf_map(inset4, col = 5, add = TRUE)
# bouger des points
pts <- st_as_sf(st_sample(x = nc[1, ], 10))
inset5 <- m_r(x = pts, mask = nc[1,], y = y[1])
mf_map(pts, cex = .2, add=TRUE)
mf_map(inset5, cex = .2, add = TRUE)
# MULTIPOINT
pts <- (st_sample(x = nc[3, ], 30))
pts <- st_as_sf(st_combine(x = pts))
inset6 <- m_r(x = pts, mask = nc[3,], y = y[5])
mf_map(pts, cex = .5, add = TRUE)
mf_map(inset6, cex = .5, add = TRUE)
# MULTILINESTRING
line <- st_cast(nc, 'MULTILINESTRING')
inset7 <- m_r(x = line, mask = line[4,], y = y[6])
mf_map(line[4, ], col = 3, add = TRUE, lwd = 3)
mf_map(inset7, add = TRUE, col = 3, lwd = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.