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, puzzles and problems to solve every day!

You have a problem, an idea for a project, a specific need and dCode can not (yet) help you? You need custom development? *Contact-me*!

Sponsored ads

Tool to decode / encode coordinates with Geohash, a geographic data representation system used on to shorten url on geohash.org

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 =1, ie 0;+90, then the left interval =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 source code of the script Geohash online. Except explicit open source licence (indicated Creative Commons / free), any algorithm, applet, snippet, software (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt, encrypt, decipher, cipher, decode, code, translate) written in any informatic langauge (PHP, Java, C#, Python, Javascript, Matlab, etc.) which dCode owns rights will not be given for free. To download the online Geohash script for offline use on PC, iPhone or Android, ask for price quote on contact page !

geohash,coordinate,latitude,longitude,gps

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

© 2018 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaches. dCode

Feedback