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.1.tar.gz (4.8 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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polygon_geohasher_2-0.0.1.tar.gz
  • Upload date:
  • Size: 4.8 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.1.tar.gz
Algorithm Hash digest
SHA256 b4045078a4f066ba8eb8f8359df4e1e3983384d212af0bd0cd47e6aa103e2c1e
MD5 6a6c5db86c32b1db424954cd7d950ee1
BLAKE2b-256 22552f3cdd08ca0c7086cef148fbe49307871caa072bfb802f51d561eb01addf

See more details on using hashes here.

Provenance

The following attestation bundles were made for polygon_geohasher_2-0.0.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for polygon_geohasher_2-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca189ea1f8f0e3d8007067ce05535614c0aecc3084dca26d313d92897fac9f7
MD5 5ce1b9979520b2698f4e138410f769a0
BLAKE2b-256 1a9ebc6b6715c342af8d44f7e52511147f5eaf7620bc0d6e27079dd40c60b2c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for polygon_geohasher_2-0.0.1-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