sm_coordinates: Customizable coordinates zoom for ggplot maps

sm_coordinatesR Documentation

Customizable coordinates zoom for ggplot maps

Description

Set coordinate limits for a ggplot map based on a sf object or a bbox object, having an option for expanding the limits (expansion)

Usage

sm_coordinates(
  data = NULL,
  bbox = NULL,
  xlim = NULL,
  ylim = NULL,
  expand = TRUE,
  crs = NULL,
  r_xmin = NULL,
  r_xmax = NULL,
  r_ymin = NULL,
  r_ymax = NULL,
  datum = sf::st_crs(4326),
  label_graticule = waiver(),
  label_axes = waiver(),
  ndiscr = 100,
  default = FALSE,
  clip = "on",
  projected_base = F,
  expansion = space(t = 0, r = 0, b = 0, l = 0)
)

Arguments

data

The dataframe containing the spatial information for the box limits.

bbox

An st_bbox objetc as a named vector for getting the box limits

r_xmin

the sf object to replace the dimension xmin

r_xmax

the sf object to replace the dimension xmax

r_ymin

the sf object to replace the dimension ymin

r_ymax

the sf object to replace the dimension ymax

projected_base

logical, if T the original source (data or bbox) is in a projected CRS

expansion

a vector trbl for expandin any dimension over the initial limits

Value

The coordinates for an accurate plot

Examples

## Not run:
librar(sf)
sf_utam %>%
ggplot() +
geom_sf(data = bogota_unido, fill = "#EBECF2") +
geom_sf(aes(fill = as.factor(ESTRATOPre)), alpha = 0.6) +
scale_fill_brewer("Estrato", palette = "YlGnBu") +
theme_void(base_family = "Franklin Gothic Book") +
theme(plot.background = element_rect(fill = "#EBECF2", color = NA),
plot.margin = margin(r = 10),
text = element_text(size = 10)) +
coord_sf_santi(bbox = a, expansion = space(r = 0.5))

samesag/emu documentation built on Aug. 22, 2023, 3:19 p.m.