Skip to main content

Reusable NYC geography resources, normalization helpers, and boundary loaders for Python tools.

Project description

nyc-geo-toolkit

Actions Status Documentation Status PyPI version PyPI platforms

nyc-geo-toolkit cover figure

Reusable NYC geography resources, normalization helpers, and boundary loaders for Python tools.

Authored by Blaise Albis-Burdige.

Why this exists

Every NYC data project needs borough boundaries, ZIP lookups, and district normalization. nyc-geo-toolkit ships canonical boundary GeoJSON and a stable Python API so downstream tools don't duplicate that work. Install the base package for zero-dependency boundary loading, or add optional extras for pandas, geopandas, and basemap helpers.

What this package provides

  • Packaged boundary layers for boroughs, community districts, council districts, NTAs, ZCTAs, and census tracts -- no runtime network dependency
  • Normalization helpers that turn messy user input ("bk", "01 Brooklyn", "zip code") into canonical values
  • Geodesy helpers for great-circle distance, walk-radius circles, and bounding boxes -- dependency-free
  • Typed models (BoundaryCollection, BoundaryFeature) for safe, inspectable boundary data
  • GeoJSON, DataFrame, and GeoDataFrame conversion with optional pandas and geopandas extras
  • Basemap and spatial helpers for Web Mercator reprojection, OSM tile overlays, and bbox clipping

Ecosystem

nyc-geo-toolkit is the shared geography core for a family of NYC data packages:

Package Description
nyc311 311 service request analysis and aggregation
subway-access Subway accessibility and coverage analysis
nyc-mesh Community mesh network coverage analysis

All three depend on the stable nyc_geo_toolkit namespace for boundary data, normalization, and spatial primitives.

Install

pip install nyc-geo-toolkit              # zero-dependency base
pip install "nyc-geo-toolkit[dataframes]" # + pandas helpers
pip install "nyc-geo-toolkit[spatial]"    # + geopandas, shapely, contextily
pip install "nyc-geo-toolkit[all]"        # everything

Quick start

Load and inspect boundaries

from nyc_geo_toolkit import list_boundary_layers, load_nyc_boundaries

print(list_boundary_layers())
# ('borough', 'community_district', 'council_district', ...)

queens = load_nyc_boundaries("borough", values="Queens")
print(queens.features[0].geography_value)  # "QUEENS"

Normalize messy input

from nyc_geo_toolkit import normalize_borough_name, normalize_boundary_value

normalize_borough_name("bk")  # "BROOKLYN"
normalize_boundary_value("community_district", "01 Brooklyn")  # "BROOKLYN 01"

Plot a boundary layer

from nyc_geo_toolkit import (
    load_nyc_boundaries_geodataframe,
    to_web_mercator,
    add_osm_basemap,
)

gdf = to_web_mercator(load_nyc_boundaries_geodataframe("borough"))
ax = gdf.plot(figsize=(8, 8), edgecolor="white", alpha=0.7, column="geography_value")
add_osm_basemap(ax)

Use geodesy helpers

from nyc_geo_toolkit import (
    haversine_distance_meters,
    walk_radius_meters,
    build_circle_polygon,
)

walk_radius_meters(10)  # 800.0 meters
haversine_distance_meters(40.7580, -73.9855, 40.7128, -74.006)  # ~5.2 km
polygon = build_circle_polygon(40.7128, -74.006, 800)  # 24-sided circle

API overview

Category Key functions
Discovery & loading list_boundary_layers(), list_boundary_values(), load_nyc_boundaries(), load_nyc_boundaries_geodataframe()
Normalization normalize_borough_name(), normalize_boundary_layer(), normalize_boundary_value(), normalize_boundary_values()
Geodesy haversine_distance_meters(), walk_radius_meters(), build_circle_polygon()
Spatial helpers add_osm_basemap(), to_web_mercator(), bbox_around(), clip_boundaries_to_bbox()
Conversion boundaries_to_geojson(), boundaries_to_dataframe()
Models & constants BoundaryCollection, BoundaryFeature, BoundaryLayerSpec, BOROUGH_*, SUPPORTED_BOROUGHS

Full reference: API docs

Examples

The repo ships self-contained examples under examples/:

Documentation

Home | Getting Started | Examples | API Reference | Architecture

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nyc_geo_toolkit-0.4.0.tar.gz (11.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nyc_geo_toolkit-0.4.0-py3-none-any.whl (10.5 MB view details)

Uploaded Python 3

File details

Details for the file nyc_geo_toolkit-0.4.0.tar.gz.

File metadata

  • Download URL: nyc_geo_toolkit-0.4.0.tar.gz
  • Upload date:
  • Size: 11.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nyc_geo_toolkit-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d44d191724138bc97324fcca0ce7b6ec06ef96ffade6df3d178482c8bf46a810
MD5 020b77403c549f30c6bd370765775471
BLAKE2b-256 60f8633d2bc86e2472ebbf447666308231bdf7bd31f88244f7f3f1009168f625

See more details on using hashes here.

Provenance

The following attestation bundles were made for nyc_geo_toolkit-0.4.0.tar.gz:

Publisher: cd.yml on random-walks/nyc-geo-toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nyc_geo_toolkit-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: nyc_geo_toolkit-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nyc_geo_toolkit-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e2f1b63e2a9a132e285e30a63f68424ff973cbd297d0a31fa13ce60ebae8f7a
MD5 19da18d360b467a293492191df1d224b
BLAKE2b-256 56373f54f92faae36cb32882f47c30522b9d409838b9b11503a9d151d64aeff0

See more details on using hashes here.

Provenance

The following attestation bundles were made for nyc_geo_toolkit-0.4.0-py3-none-any.whl:

Publisher: cd.yml on random-walks/nyc-geo-toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page