Skip to contents

Wraps the Socrata MAP VIEW derived from the main Crimes feed (parent_fxf = ijzp-q8t2). Verified live as type: map, parent_fxf: [ijzp-q8t2] via the Socrata catalog API; landing page at https://data.cityofchicago.org/Public-Safety/Crimes-2001-to-Present-Map/ahwe-kpsy.

Usage

morie_datasets_chicago_crime_map(
  date_from = NULL,
  date_to = NULL,
  where = NULL,
  max_features = NULL,
  offline = TRUE,
  resource_id = NULL,
  paginate = FALSE,
  page_size = 1000L,
  max_pages = 200L,
  app_token = NULL
)

Arguments

date_from

Lower bound on date (inclusive). Accepts a Date, POSIXct, or ISO-8601 string. NULL defaults to one year before date_to (matches the upstream Map view's rolling 1-year window).

date_to

Upper bound on date (exclusive). NULL defaults to today.

where

Optional additional SoQL WHERE fragment ANDed onto the date window. e.g. "primary_type='HOMICIDE'".

max_features

Optional total row cap.

offline

Logical; if TRUE (default), read the bundled 39-col fixture.

resource_id

Optional view id override (default "ahwe-kpsy").

paginate

Logical; opt-in pagination via baked-in LIMIT n OFFSET m.

page_size

Per-page row count when paginating.

max_pages

Safety net on paginated walks.

app_token

Optional Socrata app token (sent as X-App-Token).

Value

A data.frame with the 39-col schema.

Details

SODA3-only. The SODA2 endpoint /resource/ahwe-kpsy.json does technically return HTTP 200 but ships rows as empty objects ([{}]) – column resolution doesn't fire on map/filtered views. This loader uses the SODA3 endpoint /api/v3/views/ahwe-kpsy/query.json?query=SELECT ... WHERE ... via .morie_dataset_soda3_query().

The live ahwe-kpsy view returns a 39-column schema:

  • 22 base ijzp-q8t2 columns (id, case_number, date, ..., location)

  • 4 reverse-geocoded extras (location_address, location_city, location_state, location_zip)

  • 4 Socrata-internal metadata cols (:id, :version, :created_at, :updated_at)

  • 9 :@computed_region_* spatial-overlay columns mapping each row to other Chicago boundary layers (wards, community areas, etc.) via Socrata's automatic point-in-polygon computation

Offline mode reads a bundled 5-row 39-col fixture (inst/extdata/chicago_crime_map_ahwe_kpsy_sample.csv).

References

City of Chicago Data Portal, "Crimes - 2001 to Present - Map" (ahwe-kpsy), derived from ijzp-q8t2.

Examples

df <- morie_datasets_chicago_crime_map(offline = TRUE)
df$primary_type
#> [1] "THEFT"     "BATTERY"   "BURGLARY"  "NARCOTICS" "THEFT"