Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use as a polygon geohash? #13

Open
weiji14 opened this issue Dec 16, 2020 · 2 comments
Open

Use as a polygon geohash? #13

weiji14 opened this issue Dec 16, 2020 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@weiji14
Copy link

weiji14 commented Dec 16, 2020

Kia ora! I realize this library is still young but just had a question on using rHEALPix as a sortable polygon "geohash". I've been looking for a way to consistently index/name some polygon features (whose outlines can change slightly over time), and tried using the rhealpixdggs.conversion.get_finest_containing_cell added in #12, but it doesn't seem to work for some of the polygons I've tried.

import geopandas as gpd
import rhealpixdggs.conversion

gdf: gpd.GeoDataFrame = gpd.read_file(filename="lakeconway.geojson")
polygon: shapely.geometry.Polygon = gdf.loc[0].geometry

rhealpixdggs.conversion.get_finest_containing_cell(polygon=polygon)
# returns None instead of string like S1234567

Sample polygon is lakeconway.geojson.zip (using EPSG:4326). This is a location rather close to the South Pole (about Lat: 84.°S, Lon: 150°W). My question is whether rHEALPix-py is able to handle polar projections with some tweaking, or if there are some inherent limitations with the system.

@alpha-beta-soup
Copy link
Member

This is a key usecase, a clear method to do this will be part of v0.6.0.

@alpha-beta-soup alpha-beta-soup added this to the v0.6.0 milestone Dec 18, 2023
@alpha-beta-soup alpha-beta-soup added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 18, 2023
@ppKrauss
Copy link

ppKrauss commented Feb 11, 2024

Hello, we can collaborate with the "binary Geohash", as described for example in this article
https://mmcloughlin.com/posts/geohash-assembly
PS: is possible to adapt to binary, the neighbours operations are also fast and non-geometrical operations, as demonstrated here.

Ideally, we would also like to use PostgreSQL/PostGIS instead of Python. With PostGIS we can use PROJ's rHEALPix by registered SRID for inverse.

Binary Geohash and human representations

Other bases, in addition to the classic Geohash base32, can be used to express the cell identifier as a geocode, see for example base32nvu or base16h at this interactive illustration:

image

image

So, we can use a system of square grids with ~23 hierarchical levels, very useful for multifunctional applications.

For a complete, bit by bit cell representation... We can duplicate the number of hierarchical levels (~45) using the "degenerated grid" (rectangular), to express base32 and to quadtree applications:

image

Any "integer level", with indexes i, can be transformed into a "half level" with indexes j:

image

PS: the transformation is valid also for Hilbert curves, so is possible to express a "Hilbert Geohash", when application need continuous intervals — and the application is not concerned with aperiodicity in the degenerated grid.


Practical example of the use of the binary Geohash encode, with PostgreSQL in bigint (64 bits integer) or varbit type, and translating it to humans with base16h, for a postal address point in Brasil, national grid:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants