{"id":24257,"library":"polygon-geohasher","title":"polygon-geohasher","description":"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.","status":"active","version":"0.0.2","language":"python","source_language":"en","source_url":"https://github.com/Bonsanto/polygon-geohasher","tags":["geohash","polygon","shapely","gis","geospatial"],"install":[{"cmd":"pip install polygon-geohasher","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for polygon geometry operations","package":"shapely","optional":false},{"reason":"For encoding/decoding geohashes","package":"geohash","optional":false}],"imports":[{"note":"Top-level imports are available since 0.0.2","wrong":"from polygon_geohasher.polygon_geohasher import polygon_to_geohashes","symbol":"polygon_to_geohashes","correct":"from polygon_geohasher import polygon_to_geohashes"},{"note":"Direct top-level import works","wrong":"","symbol":"geohash_to_polygon","correct":"from polygon_geohasher import geohash_to_polygon"},{"note":"Direct top-level import works","wrong":"","symbol":"geohashes_to_polygon","correct":"from polygon_geohasher import geohashes_to_polygon"}],"quickstart":{"code":"from shapely.geometry import Polygon\nfrom polygon_geohasher import polygon_to_geohashes, geohash_to_polygon, geohashes_to_polygon\n\n# Create a simple polygon (a square near London)\npolygon = Polygon([(-0.1, 51.5), (-0.1, 51.6), (0.1, 51.6), (0.1, 51.5)])\n\n# Convert polygon to geohashes (default precision 5)\ngeohashes = polygon_to_geohashes(polygon, precision=5)\nprint('Geohashes:', geohashes[:5], '...')  # prints first 5\n\n# Convert single geohash to polygon (bounding box)\nif geohashes:\n    poly = geohash_to_polygon(geohashes[0])\n    print('Polygon from geohash:', poly.wkt)\n\n# Convert list of geohashes to polygon\npoly_union = geohashes_to_polygon(list(geohashes))\nprint('Union polygon:', poly_union.wkt)","lang":"python","description":"Basic usage: create polygon, convert to geohashes, convert back."},"warnings":[{"fix":"Choose precision based on your polygon size; typical values: 5 (approx 4.9km x 4.9km), 6 (1.2km), 7 (152m).","message":"The '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.","severity":"gotcha","affected_versions":"all"},{"fix":"No action needed, but if you relied on internal behavior, note that unary_union is used instead of cascaded_union.","message":"The 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.","severity":"deprecated","affected_versions":"0.0.2"},{"fix":"Use shapely.validation.make_valid() or buffer(0) to fix invalid geometries before passing to polygon_to_geohashes.","message":"If 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.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to latest version: pip install --upgrade polygon-geohasher, or use old import: from polygon_geohasher.polygon_geohasher import polygon_to_geohashes","cause":"Older version (<0.0.2) did not expose top-level imports; you need to import from polygon_geohasher.polygon_geohasher","error":"ImportError: cannot import name 'polygon_to_geohashes' from 'polygon_geohasher'"},{"fix":"Pass a list: geohashes_to_polygon([geohash_string])","cause":"Passing a single polygon instead of a list to geohashes_to_polygon; this function expects a list/iterable of geohash strings.","error":"TypeError: 'Polygon' object is not iterable"},{"fix":"pip install --upgrade polygon-geohasher and check import path: from polygon_geohasher import polygon_to_geohashes","cause":"Using very old version (before 0.0.2) or incorrectly installed package.","error":"AttributeError: module 'polygon_geohasher' has no attribute 'polygon_to_geohashes'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}