
Add an inset within a map
add_inset.Rd
Add an inset within a map
Arguments
- x
should be a sf object or at least readable by sf::st_geometry.
- y
should be a sf object or at least readable by sf::st_bbox.
- ratio
numeric, how big should be the inset relative to the whole map or to y. See details.
- add
loical, should the inset be added to an existing plot.
- ...
some parameters that will be used by sf::plot
Details
If add = TRUE, the location is calculated through the extent of current map. If add = FALSE, the location is calcultaed through the extent of y.
The function is based on the facility to rescale and translate sf object.
Examples
library(sf)
#> Linking to GEOS 3.12.2, GDAL 3.10.3, PROJ 9.4.1; sf_use_s2() is TRUE
so.ii::map_so_ii()
inset = add_inset(
so.ii::so_ii_inset[c("region", "so-ii"), ],
so.ii::so_ii_limit,
col = c("gray", "red"), border = c(NA, "red"), lwd = 1:2
)