Trade Offs: Geohash vs H3 vs S2 in Production
Geohash Characteristics
Geohash uses rectangular cells in a Z-order curve. Cells are not equal area: they shrink toward the poles because longitude lines converge. Simple implementation with standard string operations. Works with any database that supports prefix queries.
Limitations: cell shape varies by latitude, edge discontinuities exist (neighboring cells may have very different prefixes at certain boundaries), and rectangles are poor approximations of circular query regions.
S2 Geometry
S2 projects Earth onto a cube, then subdivides each face using a Hilbert curve. Cells are roughly equal area regardless of latitude. The Hilbert curve has better locality than Z-order: nearby points more consistently have nearby cell IDs.
S2 cells have 30 precision levels. Level 12 cells are roughly 3 km by 3 km. Level 18 cells are about 38 m by 38 m. S2 supports covering arbitrary shapes with a set of cells, useful for polygon queries. More complex to implement but better geometric properties.
H3 Hexagonal Grid
H3 uses hexagonal cells. Hexagons have consistent neighbor distances: all 6 neighbors are equidistant from the center. This eliminates the corner problem where diagonal neighbors are farther than edge neighbors in square grids.
H3 has 16 resolution levels. Resolution 7 cells are about 5 km edge to edge. Resolution 9 is about 175 m. H3 excels at aggregation and visualization because hexagons tile evenly. The trade-off is that H3 IDs are not hierarchically prefixable like geohashes.