Skip to contents

Pages through the ArcGIS /query endpoint and writes a tidy CSV to the morie cache directory. Calls back to a cached file on subsequent calls unless overwrite = TRUE.

Usage

morie_fetch_tps(
  category,
  cache_dir = file.path(tempdir(), "morie", "tps"),
  where = "1=1",
  overwrite = FALSE,
  max_per_page = 2000L
)

Arguments

category

One of names(morie_tps_layer_urls()).

cache_dir

Directory for the CSV. Defaults to a session-scoped subdirectory of tempdir() that R cleans up automatically. For persistent caching pass cache_dir = morie_cache_dir("tps"); see morie_cache_dir and morie_cache_clear.

where

ArcGIS SQL where clause (default "1=1").

overwrite

Logical; if FALSE and the CSV exists, return its path without re-downloading.

max_per_page

ArcGIS page size (default 2000; server caps).

Value

Path to the CSV.

Examples

if (FALSE) { # \dontrun{
# Network: fetches major-crime indicators from the Toronto Police
# ArcGIS open-data layer.
csv <- morie_fetch_tps(
  category = "Assault",
  cache_dir = tempdir(),
  where = "OCC_YEAR = 2024"
)
tps <- utils::read.csv(csv)
nrow(tps)
} # }