What is Geohash?

Geohash is a geocoding system that encodes geographic coordinates (latitude and longitude) into a short string of letters and digits. It was invented by Gustavo Niemeyer in 2008 and provides a hierarchical spatial data structure that divides the world into a grid of cells.

Quick Facts

Full NameGeohash Geocoding System
Created2008 by Gustavo Niemeyer
SpecificationOfficial Specification

How It Works

Geohash works by interleaving the binary representations of latitude and longitude, then encoding the result using Base32. Each character in a geohash represents a progressively smaller area, with longer strings providing greater precision. Adjacent locations often share similar prefixes, making geohashes useful for proximity searches and spatial indexing. The system is widely used in databases, caching systems, and location-based services for efficient geographic queries. Uber's H3 hexagonal hierarchical spatial index has emerged as a modern alternative to Geohash. H3 uses hexagonal cells that provide more uniform distances to neighbors and consistent area coverage. It's particularly suited for ride-sharing, delivery optimization, and spatial analytics where uniform cell properties are important.

Key Characteristics

  • Encodes lat/lng into alphanumeric string (Base32)
  • Hierarchical structure - longer strings = more precision
  • Adjacent locations share common prefixes
  • Each character adds ~5 bits of precision
  • 12-character geohash has ~3.7cm precision
  • Publicly available algorithm with no licensing restrictions

Common Use Cases

  1. Spatial database indexing and queries
  2. Location-based caching and search
  3. Proximity detection and nearby searches
  4. URL-friendly location encoding
  5. Distributed systems with location sharding

Example

loading...
Loading code...

Frequently Asked Questions

How does geohash precision relate to string length?

Each additional character in a geohash increases precision by roughly 5 bits. A 1-character geohash covers ~5,000km, 4 characters ~39km, 6 characters ~1.2km, 8 characters ~38m, and 12 characters ~3.7cm. Choose length based on your accuracy requirements.

Why do nearby locations sometimes have completely different geohashes?

This is the 'edge case' problem. Locations on opposite sides of a geohash cell boundary may have very different prefixes despite being close together. This occurs at the edges of cells and requires checking neighboring cells for proximity searches.

What characters are used in geohash encoding?

Geohash uses a Base32 alphabet consisting of 32 characters: 0-9 and b-z excluding 'a', 'i', 'l', and 'o'. These letters are excluded to avoid confusion with digits 0 and 1. The characters are: 0123456789bcdefghjkmnpqrstuvwxyz.

How is geohash used for database indexing?

Geohash enables efficient spatial queries in databases by converting 2D coordinates into a 1D string that can be indexed with standard B-tree indexes. Proximity searches use prefix matching—all locations within an area share the same geohash prefix.

What is the difference between geohash and H3?

Geohash uses rectangular cells while H3 uses hexagonal cells. H3 provides more uniform distances to neighbors and consistent area coverage. Geohash is simpler and widely supported; H3 is better for analytics requiring uniform cell properties like ride-sharing optimization.

Related Tools

Related Terms

Related Articles