Skip to contents

Wraps the City of Chicago "Boundaries - Neighborhoods" open dataset (Socrata resource id y6yq-dbs2; portal landing https://data.cityofchicago.org/Facilities-Geographic-Boundaries/Boundaries-Neighborhoods/bbvz-uum9). 98 neighbourhoods, originally derived from Neighborhoods_2012b (updated 2025-02-20). The City notes these boundaries are approximate and the names are not official.

Usage

morie_datasets_chicago_neighborhoods(
  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 attribute-only fixture from inst/extdata/chicago_neighborhoods.csv.

geometry

If TRUE and offline = FALSE, include the the_geom MultiPolygon column in the live-mode result.

max_features

Optional cap on returned rows.

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; if TRUE and offline = FALSE, walk SODA2 $offset in page_size chunks (3OO).

page_size

Per-page row count when paginating (default 1000, the unauthenticated Socrata ceiling).

max_pages

Safety net on paginated walks (default 200).

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 columns (offline mode) or 5 cols including the_geom (live mode with geometry = TRUE).

Details

Offline mode reads a bundled 98-row attribute-only fixture (pri_neigh, sec_neigh, shape_area, shape_len) – the the_geom MultiPolygon column is stripped to keep the bundled size sane (full GeoJSON is ~800 KB). Live mode hits the SODA2 endpoint via .morie_dataset_socrata_fetch() (mockable).

To get the polygons, pass geometry = TRUE in live mode, which includes the SODA2 the_geom column.

References

City of Chicago Data Portal, "Boundaries - Neighborhoods"; based on Neighborhoods_2012b.

Examples

df <- morie_datasets_chicago_neighborhoods(offline = TRUE)
head(df[, c("pri_neigh", "sec_neigh")])
#>        pri_neigh                  sec_neigh
#> 1    Albany Park     NORTH PARK,ALBANY PARK
#> 2  Andersonville              ANDERSONVILLE
#> 3 Archer Heights ARCHER HEIGHTS,WEST ELSDON
#> 4  Armour Square    ARMOUR SQUARE,CHINATOWN
#> 5        Ashburn                    ASHBURN
#> 6 Auburn Gresham             AUBURN GRESHAM