Skip to contents

Wraps the City of Chicago "Boundaries - Police Beats (current)" open dataset (Socrata resource id n9it-hstw; portal landing https://data.cityofchicago.org/Public-Safety/Boundaries-Police-Beats-current-/aerh-rz74). Returns 277 Chicago Police beats with their parent sector + district codes (verified live 2026-05). Attribute schema:

Usage

morie_datasets_chicago_police_beats(
  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 (UUID default; pass "police-beats" style alias if known).

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 4 attribute cols (offline) or 5 including the_geom (live, geometry = TRUE).

Details

beat_num

4-digit beat id (district + 2-digit beat).

beat

Within-sector beat sequence number (string).

sector

Within-district sector number (string).

district

Parent district number (string).

Offline mode reads a bundled attribute-only fixture (inst/extdata/chicago_police_beats.csv) – the the_geom MultiPolygon column is stripped to keep bundle size sane. Live mode hits the SODA2 JSON endpoint via .morie_dataset_socrata_fetch() (mockable); pass geometry = TRUE to include the_geom. Threads through the 3OO pagination args.

References

City of Chicago Data Portal, "Boundaries - Police Beats (current)" (n9it-hstw).

Examples

df <- morie_datasets_chicago_police_beats(offline = TRUE)
head(df)
#>   beat_num beat sector district
#> 1     0111    1      1        1
#> 2     0211    1      1        2
#> 3     0312    2      1        3
#> 4     0414    4      1        4
#> 5     0515    5      1        5
#> 6     0623    3      2        6