Tool to decode / encode coordinates with Geohash, a geographic data representation system used on to shorten url on geohash.org
Geohash - dCode
Tag(s) : Geography
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Geohash is the name of an algorithm, created in 2008 and deposited in the public domain, which transforms a pair (latitude, longitude) of GPS coordinates into a code of letters and numbers. This algorithm is based on a recursive division of space into grids.
The geohash algorithm uses a variant of base32 with these 32 characters 0123456789bcdefghjkmnpqrstuvwxyz. The geohash can therefore be treated as a value in base 32, convertible into binary.
Example: dc0de can be converted 12,11,0,12,13 (in base 32) or 01100,01011,00000,01100,01101 in binary (5-bit)
The binary value is divided by distinguishing 1 bit out of 2 in order to create 2 other binary numbers, the first being associated with the longitude, the second the latitude.
Example: 0110001011000000110001101 becomes 0_1_0_1_1_0_0_0_1_0_0_1_1 (longitude) and _1_0_0_0_1_0_0_0_1_0_1_0_ (latitude)
The values are then treated as a dichotomy indicator with the interval -180;+180 for longitude and -90;+90 for latitude. The idea is to split the interval in 2 at each step and take 0 for the right part and 1 for the left part. The more bits there are, the more accurate the value.
Example: The longitude 0101100010011
Bit | Left Interval | Right Interval |
---|---|---|
0 | -180;0 | |
1 | -90;0 | |
0 | -90;-45 | |
1 | -66.5;-45 | |
… | … | … |
Example: The geohash dc0de string corresponds to +6.08642578125 ; -55.39306640625
From the GPS coordinates, the geohash is calculated by creating two binary strings, one for the longitude and one for the latitude, by dichotomy of the corresponding intervals. By splitting each interval into 2 equal parts and noting 0 the left interval and 1 the right interval.
Example: Code a latitude of +12.34 starting from the interval -90;+90, take the right interval (noted 1), ie 0;+90, then the left interval (noted 0) is 0;+45, then the left interval =0 is 0;+22.5, etc… until the desired accuracy is obtained. Same for the longitude +12.34 with the interval -180;+180. The 2 numbers obtained are respectively 10010001100011001 and 100010001100011001.
From the 2 binary numbers, recompose a single binary number alternately composed of a bit of longitude and a bit of latitude
Example: 100010001100011001 and 10010001100011001 make 11000001100000011110000001111000011
Convert the resulting binary number to base 32 using the characters 0123456789bcdefghjkmnpqrstuvwxyz
Example: 11000001100000011110000001111000011 in base 2 is s60y0y3 in this special base 32
dCode retains ownership of the "Geohash" source code. Except explicit open source licence (indicated Creative Commons / free), the "Geohash" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Geohash" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Geohash" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.
The copy-paste of the page "Geohash" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Geohash on dCode.fr [online website], retrieved on 2024-11-05,