Wrapper over Shapely that returns the set of geohashes that form a Polygon.
Project description
polygon-geohasher-2
[!NOTE] This is a minimally maintained fork of the original Bonsanto/polygon-geohasher repo, which does not appear to be actively maintained.
The original project is published to PyPi under the package name
polygon-geohasher; this project is published under the package namepolygon-geohasher-2. My goal is to provide a stable package that works with all actively maintained Python versions (those with a status ofbugfixorsecurityhere). I will likely not implement any feature enhancements, but contributions are welcome!
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 | :heavy_check_mark: | :heavy_check_mark: |
| 3.11 | :heavy_check_mark: | :heavy_check_mark: |
| 3.12 | :x: | :heavy_check_mark: |
| 3.13 | :x: | :heavy_check_mark: |
| 3.14 | :x: | :heavy_check_mark: |
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:
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 .
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polygon_geohasher_2-0.2.0.tar.gz.
File metadata
- Download URL: polygon_geohasher_2-0.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbf088ebaf0e57e445cb706c449817da7765a2d9602b6fe39835a44db1820c65
|
|
| MD5 |
5906b9b67014628324927ab4a074e9ca
|
|
| BLAKE2b-256 |
ab9363252b05d079757dab14cb0037e6255dd4dad0b80315f2602ee346759600
|
Provenance
The following attestation bundles were made for polygon_geohasher_2-0.2.0.tar.gz:
Publisher:
python_publish.yml on duckontheweb/polygon-geohasher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polygon_geohasher_2-0.2.0.tar.gz -
Subject digest:
fbf088ebaf0e57e445cb706c449817da7765a2d9602b6fe39835a44db1820c65 - Sigstore transparency entry: 737985586
- Sigstore integration time:
-
Permalink:
duckontheweb/polygon-geohasher@d8943986466a86ef21af8e6475ebb1c85d7de010 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/duckontheweb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python_publish.yml@d8943986466a86ef21af8e6475ebb1c85d7de010 -
Trigger Event:
release
-
Statement type:
File details
Details for the file polygon_geohasher_2-0.2.0-py3-none-any.whl.
File metadata
- Download URL: polygon_geohasher_2-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78bc2ce629e5ca415239eccd6bc1384c90a8cb2fcce043cc26c898c0afdf7d28
|
|
| MD5 |
df8321eb80d01afd069630cb8913dec7
|
|
| BLAKE2b-256 |
e5b2bff55b80a634d147ae041b7d5ffdad84d918a21a79188edf05a71ec03020
|
Provenance
The following attestation bundles were made for polygon_geohasher_2-0.2.0-py3-none-any.whl:
Publisher:
python_publish.yml on duckontheweb/polygon-geohasher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polygon_geohasher_2-0.2.0-py3-none-any.whl -
Subject digest:
78bc2ce629e5ca415239eccd6bc1384c90a8cb2fcce043cc26c898c0afdf7d28 - Sigstore transparency entry: 737985588
- Sigstore integration time:
-
Permalink:
duckontheweb/polygon-geohasher@d8943986466a86ef21af8e6475ebb1c85d7de010 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/duckontheweb
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python_publish.yml@d8943986466a86ef21af8e6475ebb1c85d7de010 -
Trigger Event:
release
-
Statement type: