A library used for encoding/decoding geohashes.
libgeohash was originally developed by Derek Smith @ simplegeo as a BSD licensed reference implementation for the Public Domain Geohash algorithm invented in 2008 by Gustavo Niemeyer
pylibgeohash has been added under the same license as the original
To use libgeohash just run
cmake .
make
to build and test the python wrapper
python3 setup.py bdist_wheel
pip3 install dist/pylibgeohash*
Linux and Mac users can install the package via pip.
Wheel file available for ubuntu bionic
pip install pylibgeohash
c
char* hash = geohash_encode(double lat, double lng, int precision);
<do stuff>
free(hash);
python
import pylibgeohash as geohash
hash = geohash.geohash_encode(lat, lon, precision)
Takes in latitude and longitude with a desired precision and returns the correct hash value. If precision < 1 or precision > 12, a default value of 6 will be used.
c
GeoCoord coord = geohash_decode(char* hash);
coord.latitude;
coord.longitude;
python
import pylibgeohash as geohash
coord = geohash.geohash_decode("ezs42")
coord["latitude"]
coord["longitude"]
Produces an allocated GeoCoord structure which contains the latitude and longitude that was decoded from the geohash. A GeoCoord also provides the bounding box for the geohash (north, east, south, west).
c
char** geohash_neighbors(char* hash);
neighbors[0];
python
neighbors = pylibgeohash.neighbors(str_hash)
neighbors[0]
Uses the bounding box declared at hash and calculates the 8 neighboring boxes. An example is show below.
- ezefx ezs48 ezs49
- ezefr ezs42 ezs43
- ezefp ezs40 ezs41
The value returned is an array of char* with length of 8. The neighboring positions of values are shown below with each box representing the index of the array.
- 7 0 1
- 6 * 2
- 5 4 3
reponame | license | codebase | install | link |
---|---|---|---|---|
pygeohash | AGPL | pure python | pip install pygeohash |
https://github.com/wdm0006/pygeohash |
Geohash | AGPL | pure python | pip install geohash |
https://github.com/vinsci/geohash/ |
geohash2 | AGPL | pure python | pip install geohash2 |
https://github.com/DBarthe/geohash |
python-geohash | Apache2 & MIT & BSD | python & c++ | pip install python-geohash |
https://github.com/hkwi/python-geohash |
libgeohash | MIT | pure python | pip install libgeohash |
https://github.com/bashhike/libgeohash |
geohashcx | GPLv3 | python + ffi to static bin | pip install geohashcx |
https://github.com/aldnav/geohash |
pylibgeohash | BSD | c | pip install pylibgeohash |
https://github.com/bauman/libgeohash |