Python bindings for H3, a hierarchical hexagonal geospatial indexing system
84
Transform user-supplied latitude/longitude rings into the library's native polygon containers and back to GeoJSON while preserving holes and multi-shape structure.
build_shape returns an object exposing __geo_interface__ whose geometry reports type Polygon with two rings; output coordinates are [lng, lat] and both rings are closed with point counts matching the inputs (plus the closing point). @test__geo_interface__ type MultiPolygon where polygon order is preserved and each ring remains closed and intact. @testMultiPolygon with two triangles to a native shape via from_geojson then back via to_geojson returns a GeoJSON dict identical in geometry type and coordinate sequences to the original (respecting [lng, lat] ordering). @testValueError (or equivalent library error) without producing a shape. @test@generates
def build_shape(outer: list[tuple[float, float]], holes: list[list[tuple[float, float]]]] | None = None):
"""Create a native polygon shape from an outer ring and optional hole rings; returns an object exposing __geo_interface__."""
def combine_shapes(polygons: list) -> object:
"""Combine multiple polygon-like objects into a native multi-shape that exposes __geo_interface__ and preserves polygon order."""
def to_geojson(shape: object) -> dict:
"""Convert a native polygon or multi-shape into a GeoJSON-like dictionary with closed rings in [lng, lat] order."""
def from_geojson(geojson: dict) -> object:
"""Convert a GeoJSON Polygon or MultiPolygon dictionary into a native shape exposing __geo_interface__; rejects unsupported types."""Provides geospatial containers and GeoJSON interoperability.
Install with Tessl CLI
npx tessl i tessl/pypi-h3docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10