configure_inset {ggmapinset}R Documentation

Configure transformations underpinning a map inset

Description

The configuration returned by this function will normally be passed to the coordinate system via coord_sf_inset(). Currently only circular insets are supported, and only one inset per plot.

Usage

configure_inset(
  centre,
  scale = NULL,
  translation = NULL,
  radius = NULL,
  units = "km",
  crs_working = NULL
)

Arguments

centre

Coordinates of the inset centre. Ideally this should be an sfc object (see sf::st_sfc()) including a coordinate reference system. An sf::st_point() or a vector of longitude and latitude are also accepted. If a CRS cannot be determined, crs_working is assumed.

scale

Zoom scale: values larger than one will make the circle bigger.

translation

Translation (shift) of the inset relative to the centre. This can be an st_point or simply a vector of length 2 containing the x and y offsets respectively. Units are specified by crs_working.

radius

Radius of the inset circle in the units of crs_working.

units

Base length unit (e.g. "km" or "mi"). Ignored if crs_working is provided. See Details for supported values.

crs_working

The coordinate reference system to use internally when applying the transformations. See Details.

Details

The default crs_working uses the equidistant cylindrical coordinate reference system with the latitude of true scale set to match the latitude of centre. This ensures that the circle will appear circular in most cases since the projection is not distorted near the centre. The geometries are converted to this CRS for the inset transformation and constructing the inset frame, and are converted back to the CRS of centre at the end.

The default units are kilometres but can be changed with units instead of specifying the whole projection. The possible values for units are those understood by proj:

Value

An inset configuration object of class inset_config.

Examples

library(sf)

# circular inset with a 2x enlargement
cfg <- configure_inset(
  centre = st_sfc(st_point(c(-82, 35)), crs = 4326),
  scale = 2,
  translation = c(70, -180),
  radius = 50,
  units = "mi")

[Package ggmapinset version 0.3.0 Index]