32

I would like to know the precision of a Geohash with a given length. If there is a 'simple' formula you can use to calculate it, that would be extra-cool.

Wikipedia lists the precision up to 8 characters:

#   km
1   ±2500
2   ±630
3   ±78
4   ±20
5   ±2.4
6   ±0.61
7   ±0.076
8   ±0.019
5
  • 1
    What is it that you want to know?
    – Vince
    Commented Sep 26, 2014 at 12:21
  • The precision when having geohashes with 9, 10, 11.. characters
    – Gundon
    Commented Sep 26, 2014 at 12:29
  • 1
    When it comes to that, it's not so much about how decimals you have but how many that are relevant. See here for an answer to your question: gis.stackexchange.com/questions/8650/…, but pay attention to the difference between accuracy and precision.
    – Martin
    Commented Sep 26, 2014 at 12:40
  • The Wikipedia article on Geohash also states that "each subsequent bit halves [the] error." This isn't the km error (or even the decimal degree error), but rather the window/range of possible locations.
    – Erica
    Commented Sep 26, 2014 at 13:07
  • Thanks for mentioning that Erica. I did understand that, but maybe did not make myself clear enough. @Martin Geohashes are not the same thing as lat/long-coordinates, although they are derived from that.. I don't think that this question is a duplicate of the other. If it was: Can you tell me the km-window of a geohash with 9 characters?
    – Gundon
    Commented Sep 26, 2014 at 13:52

2 Answers 2

45
+100

So one symbol (letters or digits) is base 32 (5 bits). Each first bit is used for high or low window, then subsequent bits divide the precision by 2. (so divide by 8 in the best case) but there is an alternance between lat and long precision, so it ends up dividing by 4 and 8 alternatively.

With the first character, the world is split into a grid of 8 columns and 4 rows. So the size of each grid cell is 360°/8=45° in longitude, and 180°/4=45° in latitude. Considering the center of this cell, the maximum error on the location that you provide will be 22.5° of longitude and 22.5° of latitude. Because of the alternance 84 and 48, the precision (in degree) of the latitude is half of the precision of the longitude for every even number, and they are equal for every odd number. With two digits, the maximum error is 22.5°/4= 5.625° of longitude and 22.5°/8=2.8125° of latitude.

To link with Wikipedia as mentioned in the question, one degree is approximately 110km in both directions near the equator (=worst case), so you have:

#   (maximum X axis error, in km)     
1   ± 2500
2   ± 630
3   ± 78
4   ± 20
5   ± 2.4
6   ± 0.61
7   ± 0.076
8   ± 0.019
9   ± 0.0024
10  ± 0.00060
11  ± 0.000074

For a more accurate information, you should start from the lat and long errors, and compute the km precision along X-axis based on the latitude of your position (the size of the meridians doesn't change). The maximum error along the X-axis will indeed decrease when the latitude increases. For example, the precision along the X-axis inside the cell located between 45 and 90° of latitude (b,c,f,g,u,v,y,z) will be (in the worst case) 2500 km*cos(45°)~= 1770 km.

4
  • 2
    I am in between writing another answer or a comment but here it goes. Answer is logically correct but numbers are plain wrong. One letter is not 32bit but it is in base 32, which is just 5 bits. One letter can be 8bit, assuming an ascii char but that doesn't have 256 visible characters which defies readability purpose of geohash. When you have base32 you can use a limited alphabet to represent 5bits. Since this is an odd number, with each letter you can get 3lat,2lon or 2lat,3long, what geohash does is also alternate so it is 3lat,2lon then 2lat,3lon so you get even distribution.
    – auselen
    Commented Jan 20, 2017 at 11:28
  • thanks for your comment. I will check and update my answer according to your comment.
    – radouxju
    Commented Jan 20, 2017 at 12:28
  • 1
    Numbers here are wrong. Take a look at at the values here in the elastic documentation: elastic.co/guide/en/elasticsearch/reference/6.8/… I've done a sanity test and verified they are correct GeoHash-length Area width x height 1) 5,009.4km x 4,992.6km 2) 1,252.3km x 624.1km 3) 156.5km x 156km 4) 39.1km x 19.5km 5) 4.9km x 4.9km 6) 1.2km x 609.4m 7) 152.9m x 152.4m 8) 38.2m x 19m 9) 4.8m x 4.8m 10) 1.2m x 59.5cm 11) 14.9cm x 14.9cm 12) 3.7cm x 1.9cm
    – odedfos
    Commented Apr 11, 2021 at 10:36
  • thank you for your comment. My numbers represent the precision around the center of the grid cell (+ or - 2500 km from the center, so 2500 km is the MAXIMUM error that you make with a single digit), while your numbers represent the width of the grid cells. Therefore there is a factor 2 between your number and my numbers, but both make sense. I will update my answer to clarify that.
    – radouxju
    Commented Apr 12, 2021 at 11:24
1

Geohash approximates into a rectangle, so the actual, correct numbers are:

1   5,009.4km x 4,992.6km
2   1,252.3km x 624.1km
3   156.5km x 156km
4   39.1km x 19.5km
5   4.9km x 4.9km
6   1.2km x 609.4m
7   152.9m x 152.4m
8   38.2m x 19m
9   4.8m x 4.8m
10  1.2m x 59.5cm
11  14.9cm x 14.9cm
12  3.7cm x 1.9cm 

source

courtesy of @odedfos:

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Mar 13 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.