H3 & global grids

Indexing the earth into cells: H3 hexagons, S2, geohash and quadkeys — resolution, hierarchy and the joins they make cheap.

A coordinate pair turned into a cell key, after which a spatial join becomes an equality join. once it is a key, a spatial join is just a join51.5007, −0.1246needs a CRS, an index,and a geometry columnlatlng_to_cell(…, 9)89194ad14c3ffffneeds none of themmergepandas, DuckDB,BigQuery, SparkThe cost is at the edges: two points a metre apart can land in different cells and never meet

A discrete global grid turns a coordinate into a short key. That is the whole idea, and everything else follows from it: once a point is a string or a 64-bit integer, joining two datasets is an equality join, and an equality join runs in pandas, DuckDB, BigQuery, Spark or a key-value store with no CRS, no geometry column and no spatial index.

The price is at the edges. Two points a metre apart can fall in different cells and never meet; a polygon smaller than a cell can contain no cell centre and fill to nothing; and no grid gives you equal area, equal shape and simple arithmetic at once, so each system has given one of them up. Knowing which one is how you choose between H3, S2, geohash and quadkeys.

The pages below start with what the grids are and how their hierarchies work, move to the operations — indexing points, filling polygons, aggregating, joining — and end with the failures each system produces.

Learning paths run through this topic too — see the end of this page.

🧭 Start with the concepts

The ideas the how-to guides below assume you already have.

⚙️ Then do the task

Step-by-step walkthroughs with code you can copy and adapt.

Show every how-to guide in this topic

🔧 When it breaks

The errors this topic produces, with the cause explained rather than just the command.

Related topics

Subjects that keep coming up alongside this one, most overlap first.

Keep browsing

H3 & global grids sits in Geometry & space. Every topic on the site is listed on the topics index.