PyGeoHash is a Python library for working with geohashes, providing encoding, decoding, and distance calculations. It’s designed to be fast, simple, and Pythonic.
Features
- Encode/Decode: Convert latitude/longitude to geohash and back
- Distance Calculations: Calculate distances between geohashes
- Neighbor Finding: Find adjacent geohashes in any direction
- Type Hints: Full type annotation support for modern Python development
Installation
pip install pygeohash
Quick Start
import pygeohash as pgh
# Encode a location
geohash = pgh.encode(42.6, -5.6)
# Returns: 'ezs42e44yx96'
# Decode a geohash
lat, lon = pgh.decode('ezs42')
# Returns: (42.6, -5.6)
# Get neighbors
neighbors = pgh.neighbors('ezs42')