Skip to main content

Integration of rHEALPixDGGS and Pandas/GeoPandas

Project description

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.

[!IMPORTANT] This is very much a work in progress, and in the early stages. Some of the API available in h3pandas remains unimplemented, none of it has been used in production. The package comes with some tests but we make no claims of completeness regarding those.

In other words: the package in its current form is mostly meant for developers, and not in a state that would be suitable for 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.

[!NOTE] A large part of why some of the API remains unimplemented has to do with the relevant functions in the backend not being implemented yet either. Development of the wrapper API within rhealpixdggs is happening in tandem with rhppandas, with the intention of adding adapter functions one by one as the backend is fleshed out.

This also explains why environment.yml points to a branch of the rhealpixdggs-py repository instead of a release of the rhealpixdggs package.

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              
    N216055611   50   14
    N208542111   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                                         
    N216055611   50   14  POINT (14.00085 50.00206)
    N208542111   51   15  POINT (14.99814 51.00185)
  • Add cell boundaries as the geometry column:
> rhp2geoboundary = geo2rhp.rhp.rhp_to_geo_boundary()
> rhp2geoboundary
                lat  lng                                           geometry
    rhp_09                                                                 
    N216055611   50   14  POLYGON ((13.99625 50.00459, 14.0017 50.00459,...
    N208542111   51   15  POLYGON ((14.99349 51.00438, 14.99907 51.00438...
  • Add a colum with cell resolutions to the dataframe:
> withresolution = geo2rhp.rhp.rhp_get_resolution()
> withresolution
                lat  lng  rhp_resolution
    rhp_09                              
    N216055611   50   14               9
    N208542111   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                            
    N216055611   50   14             N
    N208542111   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                      
    N216055611   50   14  N21605
    N208542111   51   15  N20854
  • Add a column with the cell area:
> withcellarea = geo2rhp.rhp.cell_area()
> withcellarea
                lat  lng  rhp_cell_area
    rhp_09                             
    N216055611   50   14       0.258798
    N208542111   51   15       0.258798

Running Tests

rhppandas uses pytest as its test framework. Type pytest in a shell with an active conda environment for rhppandas.

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

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

rhppandas-0.1.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

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

rhppandas-0.1.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file rhppandas-0.1.0.tar.gz.

File metadata

  • Download URL: rhppandas-0.1.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rhppandas-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4cef8ee3648dd239c44d0b691d0fd1f4375b7d60821274ac5a9b89b6ac0a34df
MD5 2ddb735bae2a5800f5d1bfdfaa6024fd
BLAKE2b-256 9923139bf6ae0b1f2c19f84b78fcd1359947f83cd5f07d09a0e0133ae1bb9dbe

See more details on using hashes here.

File details

Details for the file rhppandas-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rhppandas-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for rhppandas-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4192168a8ef3fddb88ed519409bdbe6850f5a4ea9554790b8fe564eb93780d07
MD5 fd1e32729acd538d55f07c21f63ba54c
BLAKE2b-256 6fe45c0a6c8701d16f806717a8de4f72c2a4750fd40152cd82adfdc1db4de0f2

See more details on using hashes here.

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