Python bindings for H3, a hierarchical hexagonal geospatial indexing system
84
Build a small module that turns geographic coordinates into hexagonal cell identifiers at a chosen resolution, returns the center coordinate of a cell, and exposes the cell's boundary polygon for mapping or validation. All coordinates are (lat, lng) in decimal degrees, and cell identifiers use the library's default string form.
89283082e6bffff. @test89283082e6bffff and re-encoding that center at resolution 9 yields the same identifier. @test89283082e6bffff returns six vertices in counterclockwise order whose polygon contains (37.7749, -122.4194). @test@generates
from typing import Iterable, Sequence, Tuple
Point = Tuple[float, float]
Vertex = Tuple[float, float]
def encode_points(points: Iterable[Point], resolution: int) -> list[str]:
"""Return hex cell identifiers for each (lat, lng) point at the given resolution."""
def decode_center(cell: str) -> Point:
"""Return the center (lat, lng) for a hex cell identifier."""
def cell_boundary(cell: str) -> Sequence[Vertex]:
"""Return the ordered boundary vertices (lat, lng) for a hex cell identifier."""Provides hexagonal indexing for latitude/longitude conversion, cell centers, and cell boundaries.
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