1

I'm using Geohash library in python. Consider this code:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Geohash
>>> Geohash.decode("u3qcr")
('52.3', '21.1')
>>> Geohash.decode("u3qcx")
('52.3', '21.1')

Why do I get the same result for different hashes? Id expect the as we have different last letter we'd get different rectangles. What am I missing?

Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
Filip
  • 573
  • 5
  • 19

1 Answers1

2

Within the given precision, the coordinates are the same for both hashes. Check

>>> Geohash.decode_exactly("u3qcx")
(52.31689453125, 21.07177734375, 0.02197265625, 0.02197265625)
>>> Geohash.decode_exactly("u3qcr")
(52.27294921875, 21.07177734375, 0.02197265625, 0.02197265625)
>>> 

Compare the source for how the rounding in Geohash.decode() is calculated.

flaschbier
  • 3,910
  • 2
  • 24
  • 36
  • My output is : `(52.27294921875, 21.07177734375)` and `(52.31689453125, 21.07177734375)` so he used external library(for Linux:`apt-get install python-geohash` without rounding !). – dsgdfg Mar 19 '16 at 21:58
  • same function exists for pygeohash. Saved my day. thanks. ```import pygeohash exact_output = pygeohash.decode_exactly('tc0y3yc') ``` gives (6.7613983154296875, 79.88365173339844, 0.0006866455078125, 0.0006866455078125) – Tharaka Devinda Jun 15 '21 at 07:32