Skip to main content

rHEALPixDGGS

PyPI conda-forge Documentation Tests codecov manaakiwhenua-standards

The same rHEALPix grid shown three ways: on the globe, on the cube whose faces it defines, and on the net that cube unfolds into. Coastlines are projected through the library's own projection in all three. Dots mark the cell nuclei of the north polar face, which lie on rings of constant latitude on the globe and on concentric squares once projected.
One grid three ways: on the ellipsoid, on the cube its six faces define, and on the net that cube unfolds into. Origin longitude lon_0 = 51.8 puts the northern cube corners out at sea; the polar squares unfold at north_square=1, south_square=0.

Introduction

rHEALPixDGGS is a Python package that implements the rHEALPix Discrete Global Grid System (DGGS). rHEALPix stands for rearranged Hierarchical Equal Area isoLatitude Pixelization. HEALPix is an equal-area pixelization of the sphere from astronomy whose pixel centres lie on rings of constant latitude. rHEALPix rearranges its planar projection so that the globe unfolds into six equal squares.

The projection maps points between the ellipsoid and the plane. The grid system is built on top of it. Each square is divided into N_side × N_side equal children, and so on recursively, so every point on Earth lies in one cell at each resolution and all cells of a resolution have the same area. A cell is named by an identifier such as P40: a letter for its base square and one digit per level. Parents, children, neighbours and the topological relations between cells are computed from these identifiers. The projection is implemented in rhealpixdggs.pj_rhealpix; the grid system is rhealpixdggs.dggs.RHEALPixDGGS, with parameters N_side, the placement of the polar squares and the ellipsoid's central meridian.

Standards conformance

rHEALPixDGGS implements code to both define an rHEALPix DGGS Reference System and to perform topological queries on its identifiers. Our roadmap is for v1.0 to be fully compliant with OGC Topic 21 v2.0 / ISO 19170-1:2020. The requirement-by-requirement status is maintained in docs/source/conformance.rst.

Release Notes

This package was originally authored by Alexander Raichev in 2013 and is actively maintained. See CHANGES.rst for the release history, including explicit callouts of any breaking changes.

Error Budget

rHEALPix is a theoretically equal-area projection: all cells at a given resolution have the same area by construction. In practice, floating-point arithmetic introduces a small rounding error when computing cell areas. The RHEALPixDGGS.area_error_budget() method returns these values analytically for the default WGS84-based DGGS (WGS84_003, N_side=3, max_areal_resolution=1 m²):

Resolution Cell area (m²) Cell area (km²) Abs. tolerance (m²)
0 8.501 × 10¹³ 85,010,937 0.189
1 9.446 × 10¹² 9,445,660 0.021
2 1.050 × 10¹² 1,049,518 0.0023
3 1.166 × 10¹¹ 116,613 2.59 × 10⁻⁴
4 1.296 × 10¹⁰ 12,957 2.88 × 10⁻⁵
5 1.440 × 10⁹ 1,440 3.20 × 10⁻⁶
6 1.600 × 10⁸ 160 3.55 × 10⁻⁷
7 1.777 × 10⁷ 17.8 3.95 × 10⁻⁸
8 1.975 × 10⁶ 1.97 4.39 × 10⁻⁹
9 2.194 × 10⁵ 0.219 4.87 × 10⁻¹⁰
10 2.438 × 10⁴ 0.0244 5.41 × 10⁻¹¹
11 2,709 0.00271 6.02 × 10⁻¹²
12 301 3.01 × 10⁻⁴ 6.68 × 10⁻¹³
13 33.4 3.34 × 10⁻⁵ 7.43 × 10⁻¹⁴
14 3.72 3.72 × 10⁻⁶ 8.25 × 10⁻¹⁵
15 0.413 4.13 × 10⁻⁷ 9.17 × 10⁻¹⁶

The absolute tolerance answers the question: "how different can two computed cell areas be before we should conclude they are genuinely different, rather than just floating-point noise?" For example, at resolution 9 the tolerance is ~5 × 10⁻¹⁰ m² — if two cells' computed areas differ by less than half a nanometre squared, they should be treated as equal-area.

The relative tolerance is constant at 2.22 × 10⁻¹⁵ (10 × machine epsilon) for all resolutions, reflecting the fixed number of floating-point operations in the area formula. The absolute tolerance shrinks proportionally with cell area as resolution increases. Resolution 15 is the finest level supported by the default configuration (cells of approximately 0.41 m²).

Requirements

Dependencies are declared in pyproject.toml (this project is managed with Poetry; development dependencies are declared there too, under tool.poetry.group.dev.dependencies):

Installation

This package is available on PyPI, the Python Package Index from where it can be installed as follows:

pip install rhealpixdggs

Spherical harmonic transforms on the grid (rhealpixdggs.harmonics) need ducc0, which the harmonics extra brings:

pip install "rhealpixdggs[harmonics]"

rHEALPixDGGS is also available for download from the GitHub repository https://github.com/manaakiwhenua/rhealpixdggs-py from where the latest version can be cloned.

You can install from source using Poetry in a virtual environment (MacOS and Linux, assuming Poetry is already installed on your system):

python3 -m venv rhealpixdggs
source rhealpixdggs/bin/activate
python -m pip install --upgrade pip
poetry install

Or on Windows:

python3 -m venv rhealpixdggs
rhealpixdggs\Scripts\activate
python -m pip install --upgrade pip
poetry install

For development:

poetry shell
poetry install

Tests

The files in the tests directory test the rHEALPixDGGS modules. These files are plain unittest files (the Python testing framework contained within the standard distribution), and the examples embedded in docstrings are tested with doctest (also part of the standard distribution).

Two UNIX shell scripts are included in this repository to run all unit and doc tests:

  • scripts/run_doctests.sh
  • scripts/run_unittests.sh

Running the command python tests/test_<foo>.py performs a sequence of automated tests of <foo>.py.

For example, tests/test_cell.py automatically tests cell.py.

If you update a module, then update its test file to test the changes you made!

Test early, test often, test automatically!

There are a couple of files in the main package directory that can be used to run all tests, starting run_....

Documentation

The manual for the current master branch is published at https://manaakiwhenua.github.io/rhealpixdggs-py/. It is built with Sphinx from docs/source and the package docstrings, and redeployed by the Docs workflow on every push to master.

To build it yourself, with Sphinx and the furo theme installed (both are in the dev dependency group), run make html from the docs directory, or make latexpdf for the PDF manual, which also needs LaTeX. The output lands in docs/build.

The system itself is described in The rHEALPix Discrete Global Grid System.

License

This code is dual-licensed. You may choose to use it under either:

See the file LICENSE for more information about the dual licensing arrangement.

This dual licensing approach allows the software to be used in contexts where LGPL may not be permitted (such as certain corporate environments or standards bodies like the OGC) while still maintaining a copyleft option for those who prefer it.

Releasing

See RELEASING.md for the release process. Note that working with this repository's packaging (poetry install, poetry build, ...) requires Poetry version 2.0 or later.

A conda package rhealpixdggs is also maintained at conda-forge.

Contact

Maintainer:
Richard Law
Bioeconomy Science Institute
lawr@landcareresearch.co.nz

Original author:
Alexander Raichev
https://raichev.net/
alex@raichev.net

Former Maintainer:
Robert Gibb
Manaaki Whenua – Landcare Research
gibbr@landcareresearch.co.nz

Former Maintainer:
Dr Nicholas J. Car
SURROUND Australia Pty Ltd
nicholas.car@surroundaustralia.com

Metadata

Release files for rHEALPixDGGS 0.12.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rHEALPixDGGS 0.12.1
File Size Uploaded Provenance Actions
rhealpixdggs-0.12.1.tar.gz 10.2 MB Without provenance Details for rhealpixdggs-0.12.1.tar.gz

Built distribution (wheel)

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

Total release size: 10.3 MB

Release files / rhealpixdggs-0.12.1.tar.gz

Download URL rhealpixdggs-0.12.1.tar.gz
Size 10.2 MB
Tags Source
SHA-256 checksum
How to use checksums
8bc0062b9269e7991c28e8db83334a1fe0d417d681094636e472d1561f111c4a
BLAKE2b-256 checksum
How to use checksums
130794ed27bbca6923055c695fdbef8b77e39b73f05a76b481f2a0aa8bfefbed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.1 CPython/3.14.10 Linux/7.2.15-200.fc44.x86_64

Release files / rhealpixdggs-0.12.1-py3-none-any.whl

Download URL rhealpixdggs-0.12.1-py3-none-any.whl
Size 138.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b962bb1ad5b6fe580971928ae3d1962fc852e1f593a641c5fb4ebc40d2ba695c
BLAKE2b-256 checksum
How to use checksums
5ec3a9bda960b0d65684ef0fd8c686cc241ae46a2d2bfcbaa3a59496f877579e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.1 CPython/3.14.10 Linux/7.2.15-200.fc44.x86_64

Security for rHEALPixDGGS 0.12.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.12.1 This release

2 release files No provenance

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