Skip to contents

Wraps the City of Chicago "Boundaries - Police Districts (current)" open dataset (Socrata resource id 24zt-jpfn; portal landing https://data.cityofchicago.org/Public-Safety/Boundaries-Police-Districts-current-/fthy-xz3r). Returns 22 active districts (1-12, 14-20, 22, 24, 25) plus the special "31" headquarters polygon. Attribute schema:

Usage

morie_datasets_chicago_police_districts(
  offline = TRUE,
  geometry = FALSE,
  max_features = NULL,
  resource_id = NULL,
  mode = c("soda2", "soda3"),
  paginate = FALSE,
  page_size = 1000L,
  max_pages = 200L,
  app_token = NULL
)

Arguments

offline

If TRUE (default), read the bundled fixture.

geometry

If TRUE and offline = FALSE, include the_geom (MultiPolygon).

max_features

Optional row cap.

resource_id

Optional Socrata resource id override.

mode

One of "soda2" (default JSON resource endpoint) or "soda3" (SoQL query endpoint). 3VV+ dual-mode dispatch.

paginate

Logical; 3OO opt-in pagination.

page_size

Per-page row count when paginating.

max_pages

Safety net on paginated walks.

app_token

Optional Socrata API app token for higher rate limits; passed as the X-App-Token header.

Value

A data.frame with 2 attribute cols (offline) or 3 including the_geom (live, geometry = TRUE).

Details

dist_num

District number (string, "1"-"31").

dist_label

Display label (e.g. "1ST", "22ND").

Offline mode reads a bundled attribute-only fixture (inst/extdata/chicago_police_districts.csv). Live mode hits SODA2 JSON; pass geometry = TRUE for the_geom.

Socrata exposes this dataset in all four format permutations (SODA2 + SODA3, JSON + GeoJSON + CSV):

  • SODA2 JSON: /resource/24zt-jpfn.json

  • SODA2 GeoJSON: /resource/24zt-jpfn.geojson

  • SODA2 CSV: /resource/24zt-jpfn.csv

  • SODA3 JSON: /api/v3/views/24zt-jpfn/query.json

  • SODA3 GeoJSON: /api/v3/views/24zt-jpfn/query.geojson

morie defaults to SODA2 JSON; pass an explicit URL via resource_id to exercise the others (e.g. for direct sf reads you'd typically hit the GeoJSON variant via sf::st_read() yourself rather than going through this loader).

References

City of Chicago Data Portal, "Boundaries - Police Districts (current)" (24zt-jpfn).

Examples

df <- morie_datasets_chicago_police_districts(offline = TRUE)
head(df)
#>   dist_num dist_label
#> 1        1        1ST
#> 2        2        2ND
#> 3        3        3RD
#> 4        4        4TH
#> 5        5        5TH
#> 6        6        6TH