Skip to main content

polygon-geohasher-2

Polygon Geohasher is an open source Python package for converting Shapely's polygons into a set of geohashes. It obtains the set of geohashes inside a polygon or geohashes that touch (intersect) the polygon. This library uses python-geohash and shapely.

Requirements

Polygon Geohasher requires:

  • Python >= 3.10, < 3.15.
  • GEOS >= 3.3 (due to shapely).

Supported Python & Shapely Versions

Python Version Shapely 1 Shapely 2
3.10 ✔️ ✔️
3.11 ✔️ ✔️
3.12 ❌ ✔️
3.13 ❌ ✔️
3.14 ❌ ✔️

Installing

Linux users can get Polygon Geohasher from the Python Package Index with pip (8+):

$ pip install polygon-geohasher-2

Usage

Here are some simple examples:

from polygon_geohasher import polygon_to_geohashes, geohashes_to_polygon
from shapely import geometry

polygon = geometry.Polygon([(-99.1795917, 19.432134), (-99.1656847, 19.429034),
                            (-99.1776492, 19.414236), (-99.1795917, 19.432134)])
inner_geohashes_polygon = geohashes_to_polygon(polygon_to_geohashes(polygon, 7))
outer_geohashes_polygon = geohashes_to_polygon(polygon_to_geohashes(polygon, 7, False))

geohash_to_polygon(geohash):

This function receives a geohash and returns a Shapely's Polygon.

geohashes_to_polygon(geohashes):

This function receives a set of geohashes and returns a Shapely's Polygon or MultiPolygon.

polygon_to_geohashes(polygon, precision[, inner=True]):

This function receives a Shapely's Polygon and the precision of geohashes to be used to create a polygon and returns a set of geohashes (strings) that covers said polygon. It also receives an optional parameter inner that defines the way in which those polygons will be created. If an inner parameter is given, then only contained geohashes will be used; otherwise, intersected geohashes will be used.

See geohashed polygons resulting from both options (with and without inner) in the following example:

Example

Development

To install the development environment:

$ pip install -r requirements-dev.txt

To run the tests:

$ pytest

To run the linter:

flake8 .

Type Checking

This project uses mypy to check type annotations. Please run the following command prior to submitting a PR:

$ mypy .

Metadata

Release files for polygon-geohasher-2 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polygon-geohasher-2 0.2.0
File Size Uploaded Provenance Actions
polygon_geohasher_2-0.2.0.tar.gz 5.4 kB With provenance Details for polygon_geohasher_2-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polygon-geohasher-2 0.2.0
File Interpreter ABI Platform Actions
polygon_geohasher_2-0.2.0-py3-none-any.whl Python 3 none any Details for polygon_geohasher_2-0.2.0-py3-none-any.whl

Total release size: 11.8 kB

Release files / polygon_geohasher_2-0.2.0.tar.gz

Download URL polygon_geohasher_2-0.2.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fbf088ebaf0e57e445cb706c449817da7765a2d9602b6fe39835a44db1820c65
BLAKE2b-256 checksum
How to use checksums
ab9363252b05d079757dab14cb0037e6255dd4dad0b80315f2602ee346759600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2025.

Transparency log

Release files / polygon_geohasher_2-0.2.0-py3-none-any.whl

Download URL polygon_geohasher_2-0.2.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78bc2ce629e5ca415239eccd6bc1384c90a8cb2fcce043cc26c898c0afdf7d28
BLAKE2b-256 checksum
How to use checksums
e5b2bff55b80a634d147ae041b7d5ffdad84d918a21a79188edf05a71ec03020
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2025.

Transparency log

Security for polygon-geohasher-2 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for polygon_geohasher_2-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page