-
Notifications
You must be signed in to change notification settings - Fork 94
Home
Geohash is a string representation of two dimensional geometric coordinates. This technique is well described at Wikipedia Geohash. It is basically, a form of Z-order curve.
Quadtree can be used to construct a string representation. In this library, 0 for SW(South-West), 1 for SE, 2 for NW and 3 for NE.
Grid Square Code (JIS X 0410, search it in JIS database) is also a string representation of geometric coordinates. That grid code is utilized by Japan's government. NTT DoCoMo use modified version of that grid code.
This project will maintain fast, accurate geohash, quadhash and grid code python library.
Interface is almost compatible with Geohash (https://pypi.python.org/pypi/Geohash ).
Encoding.
>>> import geohash
>>> print 'Geohash for 42.6, -5.6:', geohash.encode(42.6, -5.6)
Geohash for 42.6, -5.6: ezs42e44yx96
Decoding. Returning values are float, which is incompatibile with Geohash.
>>> print 'Coordinate for Geohash ezs42:', geohash.decode('ezs42')
Coordinate for Geohash ezs42: (42.60498046875, -5.60302734375)
>>> print 'Exact coordinate for Geohash ezs42:\n', geohash.decode_exactly('ezs42')
Exact coordinate for Geohash ezs42:
(42.60498046875, -5.60302734375, 0.02197265625, 0.02197265625)
Python-geohash is good for ecology. This library speeds up geohashing x3.5(decoding), x4.2(encoding) compared to Geohash, and x1.5(decoding), x1.3(encoding) compared to geohasher. About x23 to geodatastore in encoding, and geodatastore does not support decoding.
With C extension in this library, hashing will be extremely fast: x4.9 for encoding and x11.6 for decoding compared to pure-python mode.
python-geohash works in pure python or with C extension. If you want to use this in pure python, just copy geohash.py to your script directory and it will work fine. If you want to enable C extension, build it in a normal way. You can also use the C geohasing routine in your C code, see src/geohash_sample.c.
Code is licensed under Apache License 2.0, MIT Licence and NEW BSD License. You can choose one of those. If you want to use the other license, please contact me.