Geohash Visualizer

What is Geohashing?

Geohash is a public domain geocoding system which encodes a geographic location (latitude and longitude) into a short string of letters and digits (alphanumeric). It's a hierarchical spatial data structure which subdivides space into buckets of grid shape, which is one of the many applications of what is known as a space-filling curve.

The key idea is that geohashes represent rectangular areas, and longer geohashes represent smaller, more precise areas nested within the area of their prefix.

Why Use Geohashing?

How It Works (Conceptual Algorithm)

Geohashing uses a process of iterative binary partitioning of the latitude and longitude ranges, interleaving the bits, and then encoding using Base32.

  1. Define Ranges: Start with the full Earth ranges: Longitude [-180, 180] and Latitude [-90, 90].
  2. Iterative Partitioning:
    • For a desired precision (length of the final hash), repeat the following steps, alternating between longitude and latitude:
    • Calculate the midpoint of the current longitude/latitude range.
    • If the point's coordinate is greater than or equal to the midpoint, assign a bit '1' and narrow the range to the upper half.
    • If the point's coordinate is less than the midpoint, assign a bit '0' and narrow the range to the lower half.
  3. Interleave Bits: Combine the longitude and latitude bits, alternating between them (e.g., `lon_bit0, lat_bit0, lon_bit1, lat_bit1, ...`).
  4. Group into 5-bit Chunks: Divide the interleaved binary string into groups of 5 bits.
  5. Base32 Encode: Convert each 5-bit chunk (representing a number 0-31) into its corresponding character using a specific Base32 character map (0-9, b-z, excluding 'a', 'i', 'l', 'o').

The final string of Base32 characters is the geohash. Longer strings provide higher precision (smaller bounding boxes).

Key Property: As mentioned, nearby points tend to have longer common prefixes in their geohash strings. This is because they often fall into the same larger bounding boxes during the initial partitioning steps.

Limitation: Points very close to each other but on opposite sides of a major division boundary (like the equator or prime meridian, or subsequent midpoints) might have very different geohashes, which is a known edge case.

Visualize Geohashing

Enter coordinates or click the map, adjust precision, and see how the geohash is generated and the map is partitioned.

Geohash Map Partitioning

Generated Geohash

(Generate to see result)

Interleaved Binary Bits

(Generate to see result)

Calculation Log

(Log messages appear here)

History

  • (No history yet)