Skip to main content

Python library for interacting with geohashes.

Project description


A python library for interacting with geohashes.

The library is divided into 3 modules:

  • geohash_base: Base functions for interacting with geohashes e.g. encode, decode, neighbors, bbox etc.
  • distance_metrics: Distance related functions e.g. distance, dimensions etc.
  • geometry: Functions for conversion of a polygon to a list of geohash and vice versa. e.g. polygon_to_geohash, geohash_to_polygon. Useful for approximating geographical regions with geohashes. Makes use of shapely library for geometric calculations.


Linux and Mac users can install the package via pip.

$ pip install libgeohash


>>> import libgeohash as gh

>>> gh.encode(57.64911, 10.40744, precision = 10)

>>> gh.decode('u4pruydqqv', errors = True)
(57.64911264181137, 10.407437682151794, 2.682209014892578e-06, 5.364418029785156e-06)

>>> gh.neighbors('u4pruydqqv')
{'ne': 'u4pruydqrn', 'e': 'u4pruydqrj', 'n': 'u4pruydqqy', 'se': 'u4pruydqrh', 
'w': 'u4pruydqqt', 'sw': 'u4pruydqqs', 'nw': 'u4pruydqqw', 's': 'u4pruydqqu'}

# Returns dimensions of the bounding box referred by the geohash in meters. (width, height)
>>> gh.dimensions('u4pruyd')
(152.9, 152.4)

# Returns the great circle distance (Haversine) between two geohashes or coordinates. 
>>> gh.distance('u4pruyd', 'u4pruyg')
  • For more functions and their usage, please refer to the doc strings.

Known issues

  • Fails to approximate a polygon spanning across the International Date Line i.e. 180/-180 longitude. Shouldn't be much of a problem since there aren't any geographical entities that actually span across it due to nature of the line itself.

If you happen to find any other bugs, please report them in the issues section.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for libgeohash, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size libgeohash-0.1.1-py2.py3-none-any.whl (7.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page