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.2.0.tar.gz (11.5 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.2.0-py3-none-any.whl (10.5 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nyc_geo_toolkit-0.2.0.tar.gz
  • Upload date:
  • Size: 11.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 c825a7de4cf7895f8b23f4d583bab6c4dcfb0b652fd7ffd728e4dded0cd9fb7d
MD5 829d66e571c1130045f4804aaf2edcee
BLAKE2b-256 1a3484cedf39044810e90dd4d762ab3ebc083ce9661853cb6edd7ba039b66784

See more details on using hashes here.

Provenance

The following attestation bundles were made for nyc_geo_toolkit-0.2.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nyc_geo_toolkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c66cbfd81a6089883b6f17bb3f1793110f07458ee5d2e2d7e86fd230a1056b1
MD5 afd54e029d0d7348559bc0d8a3d00606
BLAKE2b-256 1982e2a14cb3e98464cd16108ef546950aba06082ab600506b1c000a7d645abb

See more details on using hashes here.

Provenance

The following attestation bundles were made for nyc_geo_toolkit-0.2.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