Grids API¶
earthcatalog.grids.h3_partitioner
¶
H3 hexagonal grid partitioner.
Uses Uber's H3 <https://h3geo.org/>_ library to map geometries to
hexagonal grid cells at a configurable resolution.
Resolution guide¶
| Resolution | Avg. cell area | Global cells | Recommended use |
|---|---|---|---|
| 0 | ~4,250,000 km² | 122 | Continental-scale |
| 1 | ~607,220 km² | 842 | Production default |
| 2 | ~86,750 km² | 5,882 | Sub-regional granularity |
| 3 | ~12,390 km² | 41,162 | Dense urban datasets |
Boundary-inclusive contract¶
A polygon whose edge passes through a cell — but whose interior does not
contain that cell's centroid — is still assigned to the edge cell.
:class:H3Partitioner achieves this by combining:
h3.geo_to_cells()— cells whose center falls inside the polygon.- A densified boundary walk (
_boundary_cells) — cells touched by the polygon's exterior ring sampled at ~10 km spacing.
This guarantees no data gap at cell boundaries regardless of item shape.
Classes¶
H3Partitioner
¶
Bases: AbstractPartitioner
Returns every H3 cell that has ANY overlap with the input geometry: - Polygon/MultiPolygon: cells whose center falls inside (h3.geo_to_cells) UNION cells touched by the boundary (densified ring walk) - Point: single cell containing the point (h3.latlng_to_cell)
Source code in earthcatalog/grids/h3_partitioner.py
earthcatalog.grids.geojson_partitioner
¶
GeoJSON partitioner using an R-tree (STRtree) for fast intersection lookups.
Supports arbitrary polygon boundaries (drainage basins, polar regions, etc.). The boundaries file can be a local path or an s3:// URI; both are read via obstore so there is no dependency on requests/s3fs/boto3.
Classes¶
GeoJSONPartitioner
¶
Bases: AbstractPartitioner
Partitions geometries against a set of named polygon boundaries loaded from a GeoJSON FeatureCollection. Uses an STRtree for O(log n) lookups.
Parameters¶
boundaries_path:
Local path or s3:// URI to a GeoJSON FeatureCollection.
id_field:
The GeoJSON feature property to use as the partition key string.