Skip to main content

A toolkit for aggregating and visualizing geospatial data using H3 hexagonal grids

Project description

pypi License: MIT Python 3.10+

h3-toolkit

A Polars-native toolkit for aggregating and visualizing geospatial data using Uber's H3 spatial indexing system.

Documentation: https://h3-toolkit.readthedocs.io/

Installation

pip install h3-toolkit

# With visualization support (pydeck, mapclassify)
pip install h3-toolkit[vis]

Quick Example

import geopandas as gpd
from h3_toolkit import H3Toolkit
from h3_toolkit.aggregation import Mean, Sum

# Load your vector data (e.g., census blocks, building footprints)
gdf = gpd.read_file("your_data.geojson")

result = (
    H3Toolkit()
    .process_from_vector(gdf, resolution=9)
    .set_aggregation_strategy({
        "population": Sum(),
        "income":     Mean(),
    })
    .get_result()
)

print(result)
# shape: (n, 3)
# ┌─────────────────┬────────────┬────────┐
# │ cell            ┆ population ┆ income │
# │ ---             ┆ ---        ┆ ---    │
# │ u64             ┆ f64        ┆ f64    │
# ╞═════════════════╪════════════╪════════╡
# │ 613194865823…   ┆ 1204.0     ┆ 52300. │
# └─────────────────┴────────────┴────────┘

Features

  • Polars-native — all aggregations run on Polars, no pandas overhead
  • Chainable API — compose process_from_vector, set_aggregation_strategy, and get_result in a single pipeline
  • Multiple input formats — vector (GeoDataFrame), raster, or existing H3 cells
  • Pluggable aggregation strategiesSum, Mean, Count, EqualSplit, Centroid, and more
  • Optional visualization — built-in pydeck-based map rendering via the vis extra

Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a pull request.

License

MIT © City Science Lab @ TaipeiTech, Syuan-Bo Huang

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

h3_toolkit-0.3.16.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

h3_toolkit-0.3.16-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

Details for the file h3_toolkit-0.3.16.tar.gz.

File metadata

  • Download URL: h3_toolkit-0.3.16.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.2 Darwin/25.3.0

File hashes

Hashes for h3_toolkit-0.3.16.tar.gz
Algorithm Hash digest
SHA256 354af16b29600684983ffa406d1125bd51f555ca3524bc5c0fb8b32a9cd4e680
MD5 69af0e53531482d6fe0a1c1f7d543c24
BLAKE2b-256 794729adf3ae18f1020385b3d789f84893efff38621a7ea3a8eb161309d383ea

See more details on using hashes here.

File details

Details for the file h3_toolkit-0.3.16-py3-none-any.whl.

File metadata

  • Download URL: h3_toolkit-0.3.16-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.2 Darwin/25.3.0

File hashes

Hashes for h3_toolkit-0.3.16-py3-none-any.whl
Algorithm Hash digest
SHA256 68cc7d5b9e8fead798a1192c836d968abb121792f8b45e58df6a3438722f7805
MD5 21712434a7ad251087b57ea6573b72a3
BLAKE2b-256 e890eb4bed7aa73a7d36fe19427e146f90af96967b2ec1f748e75443a6300f2f

See more details on using hashes here.

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