Skip to contents

Walks the ArcGIS REST /query endpoint for the category's FeatureServer layer, accumulates all features in memory, and writes a single CSV file to cache_dir. Returns the CSV path.

Usage

morie_tps_fetch_category(
  category,
  cache_dir = NULL,
  where = "1=1",
  overwrite = FALSE,
  max_records_per_page = 2000L
)

Arguments

category

One of morie_tps_list_categories().

cache_dir

Directory to write the CSV into. Defaults to tempdir() (CRAN-safe; the Python default of ~/.cache/morie/tps requires R_user_dir opt-in in R).

where

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

overwrite

If FALSE and the output exists, return it without re-downloading.

max_records_per_page

Pagination size (server caps at 2000).

Value

Path to the written CSV file.

Examples

# The layers this can fetch -- a local lookup, no network.
morie_tps_list_categories()
#> [1] "Assault"                     "AutoTheft"                  
#> [3] "BicycleTheft"                "BreakAndEnter"              
#> [5] "Homicides"                   "Robbery"                    
#> [7] "ShootingAndFirearmDiscarges" "TheftFromMV"                
#> [9] "TheftOver"                  
if (FALSE) { # \dontrun{
# Each fetch is a live ArcGIS query paged 2000 records at a time.
res <- morie_tps_fetch_category(morie_tps_list_categories()[1],
                                cache_dir = tempdir())
} # }