
Fetch a TPS category from the Toronto Police ArcGIS REST endpoint
Source:R/mrm_samples.R
morie_fetch_tps.RdPages 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.
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 passcache_dir = morie_cache_dir("tps"); see morie_cache_dir and morie_cache_clear.- where
ArcGIS SQL where clause (default
"1=1").- overwrite
Logical; if
FALSEand the CSV exists, return its path without re-downloading.- max_per_page
ArcGIS page size (default
2000; server caps).
Examples
# \donttest{
if (requireNamespace("jsonlite", quietly = TRUE)) withAutoprint({
# 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)
})
#> > csv <- morie_fetch_tps(category = "Assault", cache_dir = tempdir(), where = "OCC_YEAR = 2024")
#> > tps <- utils::read.csv(csv)
#> > nrow(tps)
#> [1] 2000
# }