Skip to main content

rHP-Pandas

Package rhppandas intends to recreate for rHEALPix what h3pandas, developed by Daniel Jahn (https://github.com/DahnJ/H3-Pandas), does for h3-py, the Python binding for Uber's H3 DGGS. It provides a bridge between package rhealpixdggs and the dataframes used by pandas and geopandas.

Comments, bug reports and suggestions are all welcome.

In other words: the package in its current form is mostly meant for developers, or maybe for experienced end users.

Conda Environment

Use yaml file environment.yml to create a conda environment for basic use if you'd like to give the package a spin.

Adding yaml file environment-dev.yml to your conda environment will add the packages you need to run the automated tests.

Usage Examples

Using a basic dataframe with lat/lng coordinates:

> from rhppandas import rhppandas
> import pandas as pd
>
> basic_dataframe = pd.DataFrame({"lat": [50, 51], "lng": [14, 15]})
> basic_dataframe
       lat  lng
    0   50   14
    1   51   15
  • Add rhealpixdggs cell indices as the first column in the dataframe:
> geo2rhp = basic_dataframe.rhp.geo_to_rhp(9)
> geo2rhp
               lat  lng
    rhp_09              
    N216055147   50   14
    N208518546   51   15
  • Turn DGGS cell indices into points and add them in the geometry column:
> rhp2geo = geo2rhp.rhp.rhp_to_geo()
> rhp2geo
                lat  lng                   geometry
    rhp_09                                         
    N216055147   50   14    POINT (14.0006 49.9997)
    N208518546   51   15  POINT (15.00186 50.99928)
  • Add cell boundaries as the geometry column:
> rhp2geoboundary = geo2rhp.rhp.rhp_to_geo_boundary()
> rhp2geoboundary
                lat  lng                                           geometry
    rhp_09                                                                 
    N216055147   50   14  POLYGON ((13.99601 50.00223, 14.00145 50.00223...
    N208518546   51   15  POLYGON ((14.99721 51.0018, 15.00279 51.0018, ...
  • Add a colum with cell resolutions to the dataframe:
> withresolution = geo2rhp.rhp.rhp_get_resolution()
> withresolution
                lat  lng  rhp_resolution
    rhp_09                              
    N216055147   50   14               9
    N208518546   51   15               9
  • Add a column with the parent cell at resolution 0:
> withbasecell = geo2rhp.rhp.rhp_get_base_cell()
> withbasecell
                lat  lng rhp_base_cell
    rhp_09                            
    N216055147   50   14             N
    N208518546   51   15             N
  • Add a column with the parent cell indices at resolution 5:
> withparent = geo2rhp.rhp.rhp_to_parent(5)
> withparent
                lat  lng  rhp_05
    rhp_09                      
    N216055147   50   14  N21605
    N208518546   51   15  N20851
  • Add a column with the cell area:
> withcellarea = geo2rhp.rhp.cell_area()
> withcellarea
                lat  lng  rhp_cell_area
    rhp_09                             
    N216055147   50   14       0.219428
    N208518546   51   15       0.219428

Using a geodataframe with polygon geometry:

> import geopandas as gpd
> from shapely.geometry import box, LineString
>
> polygons = gpd.GeoDataFrame(geometry=[box(0, 0, 1, 1)], crs="epsg:4326")
  • Fill each polygon with the resolution 4 cells whose centroid it contains, one row per cell:
> polygons.rhp.polyfill(4, explode=True)
                                  geometry rhp_polyfill
    0  POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))        Q3330
  • Cover each polygon instead, keeping every cell that meets it. containment is "center" by default; "full" keeps only the cells that lie wholly within the polygon and "overlapping" keeps every cell that meets it:
> polygons.rhp.polyfill(4, explode=True, containment="overlapping")
                                  geometry rhp_polyfill
    0  POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))        Q3330
    0  POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))        P5555
    0  POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))        Q3333
    0  POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))        P5552
  • With compress=True, complete groups of sibling cells are replaced by their parent, as far up as they go. min_res stops that at a chosen resolution: polygons.rhp.polyfill(7, compress=True) returns cells at resolutions 5 to 7 here, and polygons.rhp.polyfill(7, compress=True, min_res=6) returns none coarser than resolution 6.

polyfill_resample takes the same containment and min_res arguments.

Using a geodataframe with line geometry:

> lines = gpd.GeoDataFrame(geometry=[LineString([(-20, 35), (60, 52)])], crs="epsg:4326")
  • List the resolution 1 cells each line passes through, in order. Segments are straight in longitude-latitude space by default:
> lines.rhp.linetrace(1)
                         geometry     rhp_linetrace
    0  LINESTRING (-20 35, 60 52)  [P2, Q0, N2, N1]
  • Trace the shortest path on the ellipsoid between each pair of vertices instead, with line="geodesic". The other values are "plate_carree", the default behaviour, and "plane", which reads the coordinates as planar rHEALPix x and y:
> lines.rhp.linetrace(1, line="geodesic")
                         geometry rhp_linetrace
    0  LINESTRING (-20 35, 60 52)  [P2, N2, N1]

Running Tests

rhppandas uses pytest as its test framework. Make sure that your environment includes both environment.yml and environment-dev.yml and is activated. Then type pytest in a shell with the active conda environment.

Typing pytest --cov will run the tests and print some info on test coverage of the code base.

Deployment

Releases go to PyPI, then to conda-forge via the rhppandas-feedstock.

From a clean, pushed develop:

scripts/release.sh --bump patch|minor|major

This runs the tests, bumps the version, pushes a vX.Y.Z tag and opens a draft GitHub release. Edit the notes and publish it; that triggers .github/workflows/publish.yml, which uploads to PyPI using trusted publishing (no tokens). scripts/release.sh --help lists the other options, including a TestPyPI rehearsal. The conda-forge bot then opens a feedstock PR; check its run requirements against pyproject.toml before merging.

Metadata

Release files for rhppandas 0.6.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 rhppandas 0.6.0
File Size Uploaded Provenance Actions
rhppandas-0.6.0.tar.gz 30.5 kB With provenance Details for rhppandas-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rhppandas 0.6.0
File Interpreter ABI Platform Actions
rhppandas-0.6.0-py3-none-any.whl Python 3 none any Details for rhppandas-0.6.0-py3-none-any.whl

Total release size: 54.2 kB

Release files / rhppandas-0.6.0.tar.gz

Download URL rhppandas-0.6.0.tar.gz
Size 30.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b2938057bcf1af186da8beecb710f074fa6f1d423dac34325fcd825084e24d7a
BLAKE2b-256 checksum
How to use checksums
d6721e9cc6e47d55af3b1938eeebdf93e9136cf1b1381ef7e806470df4a2eedf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / rhppandas-0.6.0-py3-none-any.whl

Download URL rhppandas-0.6.0-py3-none-any.whl
Size 23.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d432f13092f3c8655e253797533b3cdfe447f52660b5bc61e639f052d9a81af
BLAKE2b-256 checksum
How to use checksums
ffe9bf8342f219c8a2bd1eec8c955199b9f5ed2251d0a2bcd7b298e83a586367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Security for rhppandas 0.6.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 rhppandas-0.6.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 Nov 30, 2026.

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