Skip to contents

cache_imap_data() is a wrapper for get_imap_data() and getdata::cache_location_data() that save a layer from Maryland iMap or a subset of a layer to a local file. By default, the data is saved to the mapmaryland package cache folder.

Usage

cache_imap_data(
  data = NULL,
  nm = NULL,
  ...,
  location = NULL,
  name = NULL,
  label = NULL,
  fileext = "gpkg",
  filename = NULL,
  path = NULL,
  prefix = NULL,
  postfix = NULL,
  cache = TRUE,
  pkg = "getdata",
  create = TRUE,
  overwrite = FALSE,
  call = caller_env()
)

Arguments

data

Data to pass to getdata::bind_block_col(). format_parcel_data() only.

nm

Layer name identifier used to retrieve url from md_imap_index based on the snakecase "nm" column; Default: NULL.

...

Additional parameters passed to getdata::get_esri_data()

location

A sf, sfc, or bbox object (or other object convertible with sfext::as_bbox(). Required.

name

Name to make file name converted to snake case with janitor::make_clean_names(), e.g. "Residential zoning map" becomes "residential_zoning_map". If the name includes a file extension it is assumed that the filename has been provided as the name parameter.

label

Label to combine with name converted to snake case with janitor::make_clean_names(). The label is designed to identify the area or other shared characteristics across multiple data files, maps, or plots. label is ignored if name is NULL or if name includes a file extension.

fileext

File type or extension. Optional if filename or path include a file extension.

filename

File name; if filename is NULL and path does not include a file extension, name and file extension are both required.

path

Path to file or data directory. Optional. If path includes a file extension and filename and fileext are both NULL, the filename and extension included with path will be used instead. If multiple file extensions are provided to filename, path, or fileext, make_filename() will abort.

prefix

File name prefix. "date" adds a date prefix, "time" adds a date/time prefix; defaults to NULL.

postfix

File name postfix; defaults to NULL.

cache

If TRUE, path is set to the package cache directory using get_data_dir(); defaults to FALSE.

pkg

Package name passed to appname parameter of rappdirs::user_cache_dir()

create

If FALSE and path does not exist, return path with a warning. If TRUE and rlang::is_interactive() is TRUE, ask user if directory should be created. If the session not interactive and create is TRUE, a new directory will be created.

overwrite

If TRUE, remove a file with the same name and path

call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.