Skip to contents

Single 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 WHERE filter passed to FeatureServer ?where= (default "1=1").

max_features

Optional cap on returned rows. Passed as resultRecordCount to 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). Default TRUE – 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 to tempfile().

Value

A data.frame (json / csv), a parsed GeoJSON list, or a file path (binary).

Details

"json" (default)

Hits the FeatureServer /0/query?where=...&outFields=*&f=json endpoint and parses attributes into a tidy data.frame. Same path the existing TPS PSDP loaders (3FF) use; honours an arbitrary where clause and max_features cap.

"geojson"

Hits ?f=geojson and returns the raw GeoJSON as a parsed R list. Caller can pass to sf::st_read().

"csv"

Hits the Hub CSV exporter at hub.arcgis.com/api/v3/datasets/<hub_id>_0/downloads/data?format=csv and parses the returned CSV into a data.frame.

"shapefile" / "fgdb"

Downloads the binary archive (Esri Shapefile zip / File Geodatabase zip) to dest (default tempfile()) and returns the file path. Caller can sf::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.