Skip to main content

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 name polygon-geohasher-2. My goal is to provide a stable package that works with all actively maintained Python versions (those with a status of bugfix or security here). 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.x.
  • GEOS >= 3.3 (due to shapely).

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.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

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

polygon_geohasher_2-0.0.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polygon_geohasher_2-0.0.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file polygon_geohasher_2-0.0.2.tar.gz.

File metadata

  • Download URL: polygon_geohasher_2-0.0.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for polygon_geohasher_2-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e9e9364fd4518913c62032ec3d4ee230774583468a3045cb9005b0b39f5c4605
MD5 8663153eef81dbf7457996933e6b7982
BLAKE2b-256 658f596e48f8626ef406899a948355c343cd4c2713ad4938345cd5dfa8195fd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for polygon_geohasher_2-0.0.2.tar.gz:

Publisher: python_publish.yml on duckontheweb/polygon-geohasher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polygon_geohasher_2-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for polygon_geohasher_2-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 150487c143f3e56e02d2e72bcde965f06f013efe45a58e4a7f85ae0d43d98331
MD5 514f6decae0d96a09773adf4f2d6b93f
BLAKE2b-256 d747b0e390ef72b896a72503ce6241cb40dd7ea968ca0d19ba62e78a9e199479

See more details on using hashes here.

Provenance

The following attestation bundles were made for polygon_geohasher_2-0.0.2-py3-none-any.whl:

Publisher: python_publish.yml on duckontheweb/polygon-geohasher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page