Skip to main content

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.

Metadata

Release files for nyc-geo-toolkit 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nyc-geo-toolkit 0.4.1
File Size Uploaded
nyc_geo_toolkit-0.4.1.tar.gz 11.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for nyc-geo-toolkit 0.4.1
File Interpreter ABI Platform
nyc_geo_toolkit-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.1 MB

Release files / nyc_geo_toolkit-0.4.1.tar.gz

Download URL nyc_geo_toolkit-0.4.1.tar.gz
Size 11.6 MB
Tags Source
SHA-256 checksum
How to use checksums
8e28cd81511267302d41094d3765bc059b7faea5139d2ec80619df6b222d618b
BLAKE2b-256 checksum
How to use checksums
d55aa86f0d101f75d6822751b99d2136a98c088d913d9ce1eb945d2b27b6bfb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release files / nyc_geo_toolkit-0.4.1-py3-none-any.whl

Download URL nyc_geo_toolkit-0.4.1-py3-none-any.whl
Size 10.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3130b44b8315aeced757e188a3a38467d1574c7c001c44e8898c73442803083b
BLAKE2b-256 checksum
How to use checksums
4c075dde590a8cbb705e280de9146ace4427fb180e46cec566add69037ce9376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page