Ctrl + K
DocumentationLog inGet started

tessl/pypi-h3

tessl install tessl/pypi-h3@4.3.0

Python bindings for H3, a hierarchical hexagonal geospatial indexing system

Agent Success

Agent success rate when using this tile

84%

Improvement

Agent success rate improvement when using this tile compared to baseline

0.95x

Baseline

Agent success rate without this tile

88%

task.mdevals/scenario-8/

Polygon Coverage Toolkit

Derive hexagonal coverage for GeoJSON polygons and convert cell sets back into GeoJSON while respecting holes and multipolygons.

Capabilities

Cover GeoJSON polygons

  • Covering a 0.02° square around (37.78, -122.42) provided as a GeoJSON Polygon at resolution 9 returns a sorted list of unique indexes, all at resolution 9, and includes the index that covers the polygon centroid. @test

Exclude holes

  • Covering a donut-shaped polygon (outer square minus inner square) at resolution 8 excludes the index covering the inner square centroid, includes indexes just outside the hole, and preserves sorted unique output. @test

Merge multipolygon coverage

  • Covering two disjoint squares provided as a MultiPolygon at resolution 7 yields a sorted union identical to covering each square separately and merging, with no duplicate indexes. @test

Reconstruct GeoJSON from cells

  • Converting the coverage for the donut polygon back to GeoJSON with tight boundaries preserves a single outer ring with one hole, and re-covering that GeoJSON at the same resolution reproduces the identical index set. @test

Implementation

@generates

API

from collections.abc import Iterable
from typing import Any, Mapping, Sequence

def cover_geojson(geometry: Mapping[str, Any], resolution: int) -> list[str]:
    """
    Return a sorted list of unique hexagonal cell identifiers that cover the given GeoJSON Polygon or MultiPolygon.

    - Accepts GeoJSON-style dictionaries with coordinates in [lng, lat] order.
    - Validates geometry type and resolution (0-15) and rejects malformed rings.
    - Every returned identifier must be at the requested resolution.
    """

def cover_polygon(
    outer_ring: Sequence[Sequence[float]],
    holes: Sequence[Sequence[Sequence[float]]] | None,
    resolution: int,
) -> list[str]:
    """
    Convenience wrapper that accepts coordinates as (lat, lng) pairs for the outer ring and optional holes.

    - Applies the same coverage behavior and sorting guarantees as cover_geojson.
    - Rejects rings with fewer than three distinct points.
    """

def cells_to_geojson(cells: Iterable[str], tight: bool = True) -> Mapping[str, Any]:
    """
    Convert a collection of cell identifiers to GeoJSON.

    - Returns a Polygon when coverage is contiguous and tight=True, otherwise a MultiPolygon.
    - Preserves holes present in the coverage and emits coordinates in [lng, lat] order.
    - Rejects invalid cell identifiers.
    """

Dependencies { .dependencies }

h3 { .dependency }

Python hexagonal grid library used for polygon coverage and GeoJSON conversion.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/h3@4.3.x
tile.json