Metadata-Version: 2.4
Name: geolib
Version: 1.0.7
Summary: A library for geohash encoding, decoding and associated functions
Home-page: https://github.com/joyanujoy/geolib
Author: Anu Joy
Author-email: oss@cartographix.org
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

[![Build Status](https://travis-ci.org/joyanujoy/geolib.svg?branch=master)](https://travis-ci.org/joyanujoy/geolib) ![python 2.7|3.4|3.5|3.6|3.7](https://img.shields.io/badge/python-2.7|3.4|3.5|3.6|3.7-blue.svg)[![Downloads](https://pepy.tech/badge/geolib)](https://pepy.tech/project/geolib)

# Geolib
A python library for geohash encoding, decoding and finding neighbour cells. This is a python port of [Chris Veness' javascript implementation](https://www.movable-type.co.uk/scripts/geohash.html).

[Wikipedia reference](http://en.wikipedia.org/wiki/Geohash)
## 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](https://geolib.readthedocs.io/en/latest/)
