set_map_limits: Set map limits to area

View source: R/set_map_limits.R

set_map_limitsR Documentation

Set map limits to area

Description

[Deprecated]

This function is deprecated because the functionality has been incorporated into the improved maplayer::layer_neatline() function which uses a similar set of parameters.

Set limits for a map to the bounding box of an area using coord_sf(). Optionally, adjust the area size by applying a buffer and/or adjust the aspect ratio of the limiting bounding box to match a set aspect ratio.

Usage

set_map_limits(
  area = NULL,
  bbox = NULL,
  dist = NULL,
  diag_ratio = NULL,
  asp = NULL,
  crs = pkgconfig::get_config("mapbaltimore.crs", 2804),
  expand = FALSE,
  ...
)

Arguments

area

sf object to buffer and/or adjust.

bbox

bbox object to buffer and/or adjust. If an area is provided, any bbox is ignored.

dist

buffer distance in meters. Optional.

diag_ratio

ratio to set map extent based diagonal distance of area's bounding box. Ignored when dist is provided.

asp

Aspect ratio of width to height as a numeric value (e.g. 0.33) or character (e.g. "1:3").

crs

Coordinate reference system to use for coord_sf(). Default pkgconfig::get_config("mapbaltimore.crs", 2804)

expand

Default FALSE. If TRUE, use scale_y_continuous and scale_x_continuous to expand map extent to provided parameters.

...

Additional parameters to pass to coord_sf().

Details

Set map limits to area with optional buffer or aspect ratio adjustment

Value

ggplot2::coord_sf() function with xlim and ylim parameters

Examples

# Show detailed city boundary with map focused on area of Fell's Point (with 50m buffer)
library(ggplot2)

ggplot() +
   geom_sf(data = baltimore_city_detailed) +
   set_map_limits(area = get_area("neighborhood", "Fells Point"), dist = 50)

elipousson/mapbaltimore documentation built on April 2, 2024, 4:23 p.m.