geoprimsField-grade geospatial math

What is a geohash? Precision and edge cases

How a geohash is built, how big a cell each length gives, why nearby points can have different prefixes, and when to reach for H3 or S2.

For developers and gis · updated 2026-09-23

A geohash is a short string of letters and digits that names a rectangle on the map. Each character narrows the rectangle, so a longer geohash means a smaller box. Downtown Pittsburgh at 9 characters is dppn5fyxx, a box about 4.77 m tall and 3.63 m wide. Trim characters from the end and you get the larger boxes that contain it.

Why it matters

Geohashes are plain text, so they fit anywhere a string does: a database key, a URL, a log line, a cache key. Points that share a prefix are usually close together, which makes “find everything nearby” a cheap prefix query. That usefulness comes with sharp edges, and many geohash bugs come from them.

How it is worked out

A geohash is built by halving the world again and again.

  1. Start with longitude −180° to 180°. If the point is in the east half, write a 1. If it is in the west half, write a 0. Keep the half it is in.
  2. Do the same for latitude, −90° to 90°.
  3. Keep alternating, longitude first, one bit at a time.
  4. Group the bits in fives and write each group as one character from a 32-character alphabet: 0123456789bcdefghjkmnpqrstuvwxyz. The letters a, i, l, and o are left out, so they cannot be misread.

Each character carries 5 bits. Because the bits alternate and 5 is odd, one character adds 3 bits of longitude and 2 of latitude, and the next adds 2 and 3. That is why cells change shape between odd and even lengths.

Decoding runs the other way and gives a box, not a point. The geohash decoder reports the center and the margin of error. For dppn5fyxx the center is 40.4461026°, −79.9822068°, give or take 0.0000215° in each direction.

Cell size by length

Using the geohash encoder on the same point (40.446111°, −79.982222°):

Length Geohash Cell height Cell width
1 d 5,000,000 m 4,620,000 m
3 dpp 156,000 m 120,000 m
5 dppn5 4,890 m 3,720 m
6 dppn5f 611 m 930 m
7 dppn5fy 153 m 116 m
8 dppn5fyx 19.1 m 29.1 m
9 dppn5fyxx 4.77 m 3.63 m
12 dppn5fyxxjs9 0.0186 m 0.0284 m

Width depends on latitude, because meridians converge toward the poles. At 6 characters a cell is 611 m tall everywhere, but 1,220 m wide at the equator and 611 m wide at 60° N. The H3 documentation points out the same thing: geohash cells shrink in area away from the equator.

Neighbors and edge effects

Each cell has eight neighbors. The neighbors tool finds them by stepping one cell in each direction and encoding again. For dppn5fyxx, the north neighbor is dppn5fyxz and the east neighbor is dppn5fyz8. Those share most of their prefix, but not all: the east neighbor differs from the eighth character on.

At the big boundaries the prefix breaks down entirely. Four points 0.0001° north or south and east or west of 0°, 0° encode at 6 characters as:

Point Geohash
Just north and east of 0°, 0° s00000
Just north and west ebpbpb
Just south and west 7zzzzz
Just south and east kpbpbp

They share no characters at all, even though they are only a few tens of meters apart. The same thing happens, less dramatically, at every cell boundary at every length. So a prefix search for one cell will miss points just across its edge.

The fix is to search the cell and its eight neighbors. For an area, the geohash cover tool lists every cell at a chosen length that touches a box or polygon.

Rules of thumb

When to use H3 or S2 instead

Geohash is simple and needs no library. It is a good fit for coarse bucketing and string keys. Reach for something else when:

To see one place in all of them at a matched size, use the cross-index tool. For a cell size of about 150 m over Pittsburgh, it gives geohash dppn5fy (7 characters, about 133 m), H3 resolution 10 (about 123 m), and S2 level 16 (about 141 m), each measured as the square root of the cell’s area.

Common mistakes

Where the numbers come from

The encoding is Gustavo Niemeyer’s public-domain geohash, as described on the original geohash.org site. The geohash encoder shows the cell size and bounds for any point and length, and the decoder turns a geohash back into its box.

Try it: Geohash encoder

The calculator below is the real tool, running its worked example. Change any value; nothing leaves your device.

dppn5fyxx

The geohash is dppn5fyxx, a cell about 3.63 m wide.

Cell height
Cell width
South
West
North
East
Provenance
Computed by
indexing.geohash.encode 1.0.0, core 0.1.0
Model
Interleaved longitude and latitude bisection bits, base-32 encoded; sizes on the mean-radius sphere
Accuracy
Exact cell; sizes within 0.5% (spherical)
Notes
None
Cites
Niemeyer, G., geohash.org, Geohash (public domain algorithm)

Open the full tool, with your values →

Your values

Showing an example. Change anything.

Tools for this

Sources

Every number on this page comes from the tools above, which cite their sources on their own pages under "How we got this." Found a mistake? Use "Report a problem" at the bottom of the page.