geohash string length and accuracy

Raxit Sheth picture Raxit Sheth · Nov 19, 2012 · Viewed 13.2k times · Source

if length of geohash string is more, it is more accurate. But is there any direct relationship like if length is 7 it is providing 100 meter accuracy,

i.e. if two geohash (and either of their bounding box) is having first 7 char matching, both should be near 100 meter etc?

I am using geohash for finding, all near-by location for given geohash, with their distance

Also any directway to calculate distance between two geo-hash? (one way is to decode them to lat/lng, and then calculate distance)

Thanks

Answer

specialscope picture specialscope · Dec 27, 2012

Saw a lot of confusion around geohashing so I am posting my understanding so far. The principle behind geohash is very simple, you can create your own version. For instance consider following geo-point,

156.34234534,-23.343423345

In the above example, 156 represents degrees, 2 digits after decmal (34) represents decimal minute and rest, (34.5334) represents seconds.

If you remember school geography circumference of earth at equator is about 40,000kms and, number of degrees around the earth (latitudes or longitudes) is 360. So at the widest point each degree of latitude and longitude span equals to about 110kms (40,000/360).

So if you encode the above coordinates as, "156-23" (including negative sign), this will give you (110kmx110km) box.

You can go on and increase the precision, Fist digit of minute (156.3-23.3) will give you (10kmx10km) box (each minute span equals 1km).

Increase this to include first digit of second you get (100mx100m)box, each extra digit will add precision to another degree. Geohashing is just the way to represent the above figure in an encoded form. You can happily use the above format as well!