Registry / data / polygon-geohasher

polygon-geohasher

JSON →
library0.0.2pypypi✓ verified 86d ago

A lightweight wrapper over Shapely that returns the set of geohashes that form a Polygon. Current version is 0.0.2. The library has low release cadence (last release in 2023). It converts polygons to geohashes and vice versa, with optimizations like bbox gating and prepared geometry predicates.

pip install polygon-geohasher
INSTALL
IMPORT
SIG · POLYGON-GEOHASHER
P
polygon-geohasher
datapythonv0.0.2
Install
4.3s avg
Import
344ms
Disk
103MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.3s · import 0.344s · 98MB
103MB installed
● package 103MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

polygon_to_geohashes
from polygon_geohasher import polygon_to_geohashes
from polygon_geohasher.polygon_geohasher import polygon_to_geohashes
Top-level imports are available since 0.0.2
geohash_to_polygon
from polygon_geohasher import geohash_to_polygon
Direct top-level import works
geohashes_to_polygon
from polygon_geohasher import geohashes_to_polygon
Direct top-level import works

Basic usage: create polygon, convert to geohashes, convert back.

from shapely.geometry import Polygon from polygon_geohasher import polygon_to_geohashes, geohash_to_polygon, geohashes_to_polygon # Create a simple polygon (a square near London) polygon = Polygon([(-0.1, 51.5), (-0.1, 51.6), (0.1, 51.6), (0.1, 51.5)]) # Convert polygon to geohashes (default precision 5) geohashes = polygon_to_geohashes(polygon, precision=5) print('Geohashes:', geohashes[:5], '...') # prints first 5 # Convert single geohash to polygon (bounding box) if geohashes: poly = geohash_to_polygon(geohashes[0]) print('Polygon from geohash:', poly.wkt) # Convert list of geohashes to polygon poly_union = geohashes_to_polygon(list(geohashes)) print('Union polygon:', poly_union.wkt)
Debug
Known issues
gotchaThe 'precision' parameter controls geohash length; higher precision yields smaller, more geohashes. Default is 5. Using too high precision (e.g., 12) may return an extremely large set and cause memory issues.
fix
Choose precision based on your polygon size; typical values: 5 (approx 4.9km x 4.9km), 6 (1.2km), 7 (152m).
affects: all
deprecatedThe function 'polygon_to_geohashes' was renamed in 0.0.2? No, but 'cascaded_union' was replaced by 'unary_union' internally. User code using 'polygon_to_geohashes' is safe.
fix
No action needed, but if you relied on internal behavior, note that unary_union is used instead of cascaded_union.
affects: 0.0.2
gotchaIf input polygon is invalid (e.g., self-intersecting), the conversion may raise a Shapely exception or produce unexpected results. The library does not validate polygons.
fix
Use shapely.validation.make_valid() or buffer(0) to fix invalid geometries before passing to polygon_to_geohashes.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'polygon_to_geohashes' from 'polygon_geohasher'
Older version (<0.0.2) did not expose top-level imports; you need to import from polygon_geohasher.polygon_geohasher
fix
Upgrade to latest version: pip install --upgrade polygon-geohasher, or use old import: from polygon_geohasher.polygon_geohasher import polygon_to_geohashes
TypeError: 'Polygon' object is not iterable
Passing a single polygon instead of a list to geohashes_to_polygon; this function expects a list/iterable of geohash strings.
fix
Pass a list: geohashes_to_polygon([geohash_string])
AttributeError: module 'polygon_geohasher' has no attribute 'polygon_to_geohashes'
Using very old version (before 0.0.2) or incorrectly installed package.
fix
pip install --upgrade polygon-geohasher and check import path: from polygon_geohasher import polygon_to_geohashes
Upgrade
Version history
0.0.2latest on PyPI · released Feb 11, 2026
Audit
Dependencies
shapelyrequiredCore dependency for polygon geometry operations
geohashrequiredFor encoding/decoding geohashes
Agent activity
8 hits · last 30 days
node
8
Resources
polygon-geohasher — pip install polygon-geohasher · libregistry