Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geolib

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geolib

A library for geohash encoding, decoding and associated functions

  • 1.0.7
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc