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.

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 online 'Geohash' tool source code. Except explicit open source licence (indicated CC / Creative Commons / free), any 'Geohash' algorithm, applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any 'Geohash' function (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and no data download, script, copy-paste, or API access for 'Geohash' will be for free, same for offline use on PC, tablet, iPhone or Android ! dCode is free and online.

Please, check our dCode Discord community for help requests!

NB: for encrypted messages, test our automatic cipher identifier!

geohash,geo,hash,coordinate,latitude,longitude,gps

Source : https://www.dcode.fr/geohash-coordinates

© 2021 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback

▲
Thanks to your feedback and relevant comments, dCode has developed the best 'Geohash' tool, so feel free to write! Thank you!