Skip to main content

A library for geohash encoding, decoding and associated functions

Project description

Build Status python 2.7|3.4|3.5|3.6|3.7Downloads

Geolib

A python library for geohash encoding, decoding and finding neighbour cells. This is a python port of Chris Veness' javascript implementation.

Wikipedia reference

Installation

pipenv install geolib or pip install geolib

Usage

from geolib import geohash

Encode a latitude, longtiude to geohash

geohash.encode(latitude, longitude, precision)
>>> geohash.encode('70.2995', '-27.9993', 7)
>>> gkkpfve

Decode a geohash to latitude, longitude

geohash.decode(geohash), returns latitude, longitude as tuple of decimals
>>> geohash.decode('gkkpfve')
>>> (70.2995, -27.9993)

Find neighbouring cells of a geohash

geohash.neighbours(geohash) 
retuns a namedtuple (n, ne, e, se, s, sw, w, nw)    

>>> neighbours = geohash.neighbours('gcpuyph')
>>> neighbours
>>> ('gcpuypk', 'gcpuypm', 'gcpuypj', 'gcpuynv', 'gcpuynu', 'gcpuyng', 'gcpuyp5', 'gcpuyp7')
>>> neighbours.ne
>>> gcpuypm

Find adjacent cell in a given direction

geohash.adjacent(geohash, direction)
>>> geohash.adjacent('gcpuyph', 'n')
>>> gcpuypk

Find SW/NE latitude/longitude bounds of a geohash

geohash.bounds(geohash)
returns a namedtuple ((sw_lat, sw_lon), ((ne_lat, ne_lon))
>>> bounds = geohash.bounds('ezs42')
>>> bounds
>>> ((42.583, -5.625), (42.627, -5.58)))
>>> bounds.sw.lat 
>>> 42.583

Documentation

Geolib readthedocs

Project details


Download files

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

Source Distribution

geolib-1.0.5.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geolib-1.0.5-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file geolib-1.0.5.tar.gz.

File metadata

  • Download URL: geolib-1.0.5.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for geolib-1.0.5.tar.gz
Algorithm Hash digest
SHA256 bfb227a82ecc9c845ff17221c3cfc2bae47c44d0c562599d59499a47574ebcef
MD5 bfda5e7a610afdc5a8dc942f8950921b
BLAKE2b-256 6dcb4a7aba75f2593a95202f5041875dab32359ed4d78d684c0b04ce37afe963

See more details on using hashes here.

File details

Details for the file geolib-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: geolib-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for geolib-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 35848a01315b5c243bcdb72d0bfb4ca3c4c50b38cb744153071912a37420945a
MD5 458c7be2c959500a70bc8710cfbfbb70
BLAKE2b-256 7c0eddf258fb580809f16aead2bc1e61e5f0071b7beebd262657ec693dc54343

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page