Skip to contents

This batch loading/saving function is less flexible than get_area_data() can reduce the need for repetitive calls to get_area_data() when gathering area-level data for mapping.

  • get_data_batch() calls get_area_data().

  • get_area_batch() calls get_area() using the provided area as the location parameter.

Usage

get_data_batch(
  get = NULL,
  area = NULL,
  label = get,
  adj = list(dist = 15, diag_ratio = NULL, asp = "6:4"),
  fn = NULL,
  batch = NULL,
  crop = TRUE,
  trim = FALSE,
  load = TRUE,
  cache = FALSE,
  save = FALSE,
  filetype = "geojson",
  crs = pkgconfig::get_config("mapbaltimore.crs", 2804),
  ...
)

get_area_batch(
  get = NULL,
  area = NULL,
  label = get,
  adj = list(dist = 15, diag_ratio = NULL, asp = "6:4"),
  fn = NULL,
  batch = c("neighborhood", "council district", "csa", "tract"),
  trim = FALSE,
  load = TRUE,
  save = FALSE,
  cache = FALSE,
  filetype = "geojson",
  crs = pkgconfig::get_config("mapbaltimore.crs", 2804),
  ...
)

Arguments

get

Type of geography to use in setting the area of data to load or save. Supported values area "area", "street", or "intersection". Default: NULL

area

An sf object to use instead of getting an area, street, or intersection. Only used if get is NULL.

label

Label to use for the loaded objects or saved files, Defaults to the same as the get parameter.

adj

Named list with parameters used by adjust_bbox() to create a bounding box for the area, street, or intersection. Set to NULL if to use the area as is (or to use another sf object with the other_area parameter) Default: list(dist = 15, diag_ratio = NULL, asp = "6:4").

fn

Function to apply to area after returning it. Useful for applying a buffer to a street or creating a walking distance isochrone to use as the bounding box for an intersection.

batch

A character string or named list.

  • If using get_area_batch(), batch must be a character vector or list with the type(s) of area supported by get_area(). Any area intersecting with the area or adjusted area is returned. Default: "neighborhood", "council district", "csa", "tract"

  • If using get_data_batch(), batch must be a character vector matching one of the spatial datasets included with the mapbaltimore package or cached in advance. "osm_buildings" is a special supported parameter that calls get_area_osm_buildings() to return all building footprints in the bounding box. Default: c("streets", "parks", "zoning", "hmt_2017", "mta_bus_lines", "mta_bus_stops", "trees", "vegetated_area", "unimproved_property"). A named list where list items are sf objects, supported character strings, or valid URLs for ArcGIS FeatureServer or MapServer layers is also supported. Default: NULL

crop

If FALSE, return data that intersects with the bounding box of the area, street, or intersection but do not crop to the bounding box. This parameter is not supported for get_area_batch(). Default: TRUE.

trim

If TRUE (and if adj is NULL), trim the data to the area, street, or intersection. Default: FALSE.

load

If TRUE, load the datasets to the global environment, Default: TRUE

cache

If TRUE, cache the datasets to the package cache folder with cache_baltimore_data(). Default FALSE.

save

If TRUE, save the selected areas and datasets locally as a file (using the filetype parameter as a file extension)., Default: FALSE

filetype

File extension supported by sf::write_sf(), Default: 'geojson'

crs

Coordinate reference system

...

Parameters passed to get_area(), get_streets(), or get_intersection() depending on the value of the get parameter.

Examples

if (FALSE) { # \dontrun{
if (interactive()) {
  # Load streets and cached edge of pavement data for the Harwood neighborhood
  get_data_batch(
    get = "area",
    label = "harwood",
    type = "neighborhood",
    area_name = "Harwood",
    batch = c("streets", "edge_of_pavement"),
    load = TRUE,
    save = FALSE
  )

  # Save parks, trees, and vegetated area w/in 800 meters
  # of the intersection of E. Pratt and Light Sts. to GeoJSON files
  get_data_batch(
    get = "intersection",
    street_names = "E PRATT ST & LIGHT ST",
    adj = list(dist = 0, diag_ratio = NULL, asp = "1:1"),
    dist = 800,
    batch = c("parks", "trees", "vegetated_area")
  )
}
} # }