Generic TPS ArcGIS Hub dataset loader by hub_id
Source:R/datasets_tps_arcgis_hub.R
morie_datasets_tps_arcgis_hub_by_id.RdSingle entry point for the 71 datasets listed by
morie_datasets_tps_arcgis_hub_layers(). Supports five export
formats:
Usage
morie_datasets_tps_arcgis_hub_by_id(
hub_id,
format = "json",
where = "1=1",
max_features = NULL,
layer_idx = 0L,
offline = TRUE,
dest = NULL
)Arguments
- hub_id
32-char hex GUID. See
morie_datasets_tps_arcgis_hub_layers()for the canonical 71.- format
One of
"json"(default),"geojson","csv","shapefile","fgdb".- where
SoQL-style
WHEREfilter passed to FeatureServer?where=(default"1=1").- max_features
Optional cap on returned rows. Passed as
resultRecordCountto FeatureServer; ignored for binary formats.- layer_idx
Integer index of the FeatureServer layer to pull (default
0L, the first layer).- offline
Logical; if
TRUE, the hub_id is resolved via the bundled catalog (no network needed for the resolution step). DefaultTRUE– you can run this against the 71 catalog entries without network. Live data fetches always hit the network regardless of this argument; "offline" here only affects the hub_id -> FeatureServer URL lookup.- dest
Optional path for binary downloads (
format %in% c("shapefile", "fgdb")); defaults totempfile().
Details
"json"(default)Hits the FeatureServer
/0/query?where=...&outFields=*&f=jsonendpoint and parses attributes into a tidydata.frame. Same path the existing TPS PSDP loaders (3FF) use; honours an arbitrarywhereclause andmax_featurescap."geojson"Hits
?f=geojsonand returns the raw GeoJSON as a parsed R list. Caller can pass tosf::st_read()."csv"Hits the Hub CSV exporter at
hub.arcgis.com/api/v3/datasets/<hub_id>_0/downloads/data?format=csvand parses the returned CSV into adata.frame."shapefile"/"fgdb"Downloads the binary archive (Esri Shapefile zip / File Geodatabase zip) to
dest(defaulttempfile()) and returns the file path. Caller cansf::st_read()the unzipped contents.
For boundary layers (Police Divisions, Patrol Zone, Facilities)
you'll typically want format = "geojson" to get the polygon
geometry. For tabular outputs (UoF tables, KSI counts, ASR
tables, budgets) format = "json" is sufficient and lightest.