tessl install tessl/pypi-h3@4.3.0Python 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%
Create a small utility that summarizes where an input H3 cell sits in the hierarchy, including its parent at a coarser resolution, every child at a finer resolution, the center child, and the child's positional index within its parent.
8928308280fffff, a parent resolution of 7, and a child resolution of 9, return the parent index at resolution 7 and the full list of resolution 9 children for that parent. The children list must contain 49 entries and include the original cell. @test@generates
from typing import TypedDict
class HierarchySummary(TypedDict):
parent: str
parent_resolution: int
children: list[str]
child_resolution: int
center_child: str
center_is_input: bool
child_position: int
reconstructed_child: str
def summarize_hierarchy(cell: str, parent_resolution: int, child_resolution: int) -> HierarchySummary:
"""
Build a hierarchy summary for a given cell.
Args:
cell: H3 cell index string at resolution >= parent_resolution
parent_resolution: target coarser resolution for parent lookup
child_resolution: target finer resolution for enumerating children
Returns:
Summary describing the parent index, children at the child resolution,
whether the input is the center child, and a roundtrip reconstruction
of the original cell from its positional index within the parent.
"""Provides hierarchical traversal between parent and child cells plus position mapping.