Skip to contents

Helper function to make a ggplot2 layer from data returned by get_location

Usage

layer_show_location(
  mapping = ggplot2::aes(),
  data = NULL,
  type = NULL,
  name = NULL,
  id = NULL,
  location = NULL,
  name_col = "name",
  id_col = "id",
  index = NULL,
  label = NULL,
  label_geom = NULL,
  label_col = name_col,
  union = FALSE,
  smooth = TRUE,
  crs = NULL,
  color = "gray40",
  linetype = "dashed",
  size = 1,
  fill = NA,
  dist = NULL,
  diag_ratio = NULL,
  unit = NULL,
  asp = NULL,
  mask = FALSE,
  neatline = FALSE,
  ...
)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

Data for location to show.

type

Type of location to return. Type can be an sf object, e.g. a data frame with multiple neighborhoods or a character string that can be passed to get_location_data. If index is provided, character can also be a character string to match the name of a list.

name

Location name to return.

id

Location id to return. id is coerced to character or numeric to match the class of the id_col for type.

location

An address, bounding box (bbox), or simple feature (sf) object passed to sf::st_filter. Any valid address or addresses are geocoded with tidygeocoder::geo, converted to a simple feature object, and then used as a spatial filter. bbox objects are converted using sf_bbox_to_sf(). Multiple addresses are supported.

name_col

Column name in type with name values, Default: 'name' Required if name provided.

id_col

Column name in type with id values, Default: 'id'. Required if id is provided.

index

Optional list used to match type to data, Default: NULL

label

label type (e.g. "text", "label")

label_col

Column name or id for a column with the text or labels to pass to any text geom.

union

If TRUE, the location geometry is unioned with sf::st_union and the names are combined into a single value. Default: FALSE.

crs

Coordinate reference system to return; defaults to NULL which returns data using the same coordinate reference system as the provided type of location.

color

Color for location; defaults to "black".

linetype

Line type for location; defaults to "dashed".

fill

Fill for location; defaults to "NA".

dist

buffer distance in units. Optional.

diag_ratio

ratio of diagonal distance of area's bounding box used as buffer distance. e.g. if the diagonal distance is 3000 meters and the "diag_ratio = 0.1" a 300 meter will be used. Ignored when dist is provided.

unit

unit to adjust location by dist or diag_ratio; defaults to "meter"

asp

Aspect ratio of width to height as a numeric value (e.g. 0.33) or character (e.g. "1:3"). If numeric, get_asp() returns the same value without modification.

mask

A sf or bbox object to define the edge of the mask. diag_ratio, dist, and asp parameters are ignored if a mask is provided. defaults to NULL

neatline

If TRUE, add layer_neatline with expand = TRUE; defaults to FALSE.

...

Additional parameters passed to get_location if data is NULL.

Value

list of ggplot2 geoms

See also