Morton numbering and indexing for healpix grids
Project description
mortie
Mortie is a library for applying morton indexing to healpix grids. Morton numbering (also called z-ordering) facilitates several geospatial operators such as buffering and neighborhood look-ups, and can generally be thought of as a type of geohashing.
This particular implementation focuses on hierarchical healpix maps, and is mostly inspired from this paper.
Performance
Mortie uses Rust-accelerated morton indexing functions for high performance. The Rust implementation provides dramatic speedups:
| Dataset Size | Rust | Python (reference) | Speedup |
|---|---|---|---|
| 1,000 values | 1.93 ms | 4.14 ms | 2.1x |
| 100,000 values | 1.85 ms | 410.59 ms | 222x |
| 1.2M coordinates | 102.51 ms | 5.1 sec | 50x |
Pre-built wheels are available for Linux, macOS, and Windows. The Rust extension is required and is included in all pip-installed wheels.
Installation
pip install mortie
For development builds with Rust, see BUILDING.md.
Spatial Buffer
Mortie provides a morton_buffer function for expanding a set of morton cells by a configurable border ring. This is useful for... well, buffering.
import numpy as np
import mortie
# Convert coordinates to morton cells at order 6
cells = np.unique(mortie.geo2mort(lats, lons, order=6))
# Expand by 1-cell ring (8-connected neighbors)
border = mortie.morton_buffer(cells, k=1)
expanded = np.union1d(cells, border)
All input indices must be at the same order. The function returns only the new border cells, not the input cells themselves.
Polygon Coverage
morton_coverage computes the set of morton indices that cover a polygon defined by lat/lon vertices. It uses a top-down hierarchical descent over the HEALPix tree: starting from the 12 base cells it keeps cells inside the polygon, prunes cells outside, and refines cells the boundary passes through down to the requested order. Cost scales with the polygon's boundary, not its area — interior regions collapse to a few coarse cells, so a large but simple polygon is cheap. Vertex count still matters (a one-time O(V) edge/seed setup, plus per-boundary-cell work that grows with local edge density), but far more gently than the old O(cells × vertices) approach — a 1M-vertex polygon covers in ~1 s, roughly 40× faster than before.
import mortie
# Define polygon vertices (lat, lon in degrees)
lats = [40.0, 40.0, 50.0, 50.0]
lons = [-125.0, -115.0, -115.0, -125.0]
# Flat cover — every cell at order 6
cells = mortie.morton_coverage(lats, lons, order=6)
# Compact Multi-Order Coverage — coarse interior, fine boundary (usually far smaller)
moc = mortie.morton_coverage_moc(lats, lons, order=10)
# Adaptive boundary: stop at an angular tolerance, or cap the cell count
moc_tol = mortie.morton_coverage_moc(lats, lons, order=10, tolerance=0.5) # degrees
moc_bud = mortie.morton_coverage_moc(lats, lons, order=10, max_cells=500)
The function handles concave polygons, antimeridian-crossing polygons, and polar regions. Multipart polygons and holes are supported by passing a list of rings (even-odd fill): disjoint parts are unioned and a nested ring carves a hole, so a donut is [outer, hole]. Helpers compress_moc (merge 4-sibling groups) and moc_to_order (densify a MOC to a flat order) round out the API. See docs/coverage_methods.md for the full method/precision/runtime trade-offs and a benchmark matrix.
Dependencies
numpy. All HEALPix operations use the Rust-native healpix crate bundled in the compiled extension — no external HEALPix library is needed.
Funding
Initial funding of this work was supported by the ICESat-2 project science office, at the Laboratory for Cryospheric Sciences (NASA Goddard, Section 615).
References
[1] Youngren, Robert W., and Mikel D. Petty. "A multi-resolution HEALPix data structure for spherically mapped point data." Heliyon 3.6 (2017): e00332. doi: 10.1016/j.heliyon.2017.e00332
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mortie-0.8.5.tar.gz.
File metadata
- Download URL: mortie-0.8.5.tar.gz
- Upload date:
- Size: 16.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36178d8631c23ec557a9a417325a09c92be5d6471a9696b75ed5e59d46633d1e
|
|
| MD5 |
886fe8e83a2a6233cd6d9517f4dfbfad
|
|
| BLAKE2b-256 |
6d437b9f4ae64ea74b3b5337eda0823fe99e26d9b0e24f1564e182cddfbf953a
|
Provenance
The following attestation bundles were made for mortie-0.8.5.tar.gz:
Publisher:
build-wheels.yml on espg/mortie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortie-0.8.5.tar.gz -
Subject digest:
36178d8631c23ec557a9a417325a09c92be5d6471a9696b75ed5e59d46633d1e - Sigstore transparency entry: 2071778499
- Sigstore integration time:
-
Permalink:
espg/mortie@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/espg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mortie-0.8.5-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: mortie-0.8.5-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 14.5 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad811983c24f449606bf6a22f35266ec1e77aa8b354b37f43b2a5581750c6d5e
|
|
| MD5 |
f51fe9d02b700216be628a4141584964
|
|
| BLAKE2b-256 |
53af6910f4b764b31276101b88fdbf9c75891bb2c78856b1dc119788327acc3a
|
Provenance
The following attestation bundles were made for mortie-0.8.5-cp310-abi3-win_amd64.whl:
Publisher:
build-wheels.yml on espg/mortie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortie-0.8.5-cp310-abi3-win_amd64.whl -
Subject digest:
ad811983c24f449606bf6a22f35266ec1e77aa8b354b37f43b2a5581750c6d5e - Sigstore transparency entry: 2071778969
- Sigstore integration time:
-
Permalink:
espg/mortie@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/espg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mortie-0.8.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: mortie-0.8.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 14.5 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1933759f6b03cb704bfa2a6c6e95a7440d5f969cf9fcfc437b4e3c72c76c4889
|
|
| MD5 |
0c8583722c773937885972e198d1ee05
|
|
| BLAKE2b-256 |
ff4b56e7802e012435b89a7bd4de0feaccf09b4a1ec8eeaf09651a5d98ab1c8c
|
Provenance
The following attestation bundles were made for mortie-0.8.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
build-wheels.yml on espg/mortie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortie-0.8.5-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
1933759f6b03cb704bfa2a6c6e95a7440d5f969cf9fcfc437b4e3c72c76c4889 - Sigstore transparency entry: 2071778806
- Sigstore integration time:
-
Permalink:
espg/mortie@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/espg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mortie-0.8.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: mortie-0.8.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 14.5 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1810478270af7bc1acca144f720e803feb92c187c8c790e1f783fe0d829411e
|
|
| MD5 |
337e807cd506b1a43d6cc5fc19830df0
|
|
| BLAKE2b-256 |
f67a3846930e17d6b11fede46d5b881f44be44047d204c295a57c91284e317fd
|
Provenance
The following attestation bundles were made for mortie-0.8.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
build-wheels.yml on espg/mortie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortie-0.8.5-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
f1810478270af7bc1acca144f720e803feb92c187c8c790e1f783fe0d829411e - Sigstore transparency entry: 2071778599
- Sigstore integration time:
-
Permalink:
espg/mortie@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/espg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mortie-0.8.5-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: mortie-0.8.5-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 14.4 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b7de20dffb1cd14e350d884aaf295a5fbd6d1e7cb6947d4d991aaf7de486ee9
|
|
| MD5 |
9b5b0a56a237e8fa22cf8cdd979232a6
|
|
| BLAKE2b-256 |
a31d6a734c5a63fd468fc98a56705dcbfad95a9e42c98f508f55a3a7137ed51b
|
Provenance
The following attestation bundles were made for mortie-0.8.5-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
build-wheels.yml on espg/mortie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortie-0.8.5-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
4b7de20dffb1cd14e350d884aaf295a5fbd6d1e7cb6947d4d991aaf7de486ee9 - Sigstore transparency entry: 2071778896
- Sigstore integration time:
-
Permalink:
espg/mortie@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/espg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mortie-0.8.5-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: mortie-0.8.5-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 14.5 MB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
830d8b6dc0afa9970e32718f4ea23931fcef4335b119fd70476872ec61868cd4
|
|
| MD5 |
76bf03fef218cd846cdb65c88c4997dc
|
|
| BLAKE2b-256 |
441ffd6e864ce2082f186fb8c19340a739f36ea3cd7cac761e5f70e6238f5d28
|
Provenance
The following attestation bundles were made for mortie-0.8.5-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
build-wheels.yml on espg/mortie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mortie-0.8.5-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
830d8b6dc0afa9970e32718f4ea23931fcef4335b119fd70476872ec61868cd4 - Sigstore transparency entry: 2071778712
- Sigstore integration time:
-
Permalink:
espg/mortie@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Branch / Tag:
refs/tags/0.8.5 - Owner: https://github.com/espg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-wheels.yml@4fb4cd29bc6dc5aad3ac1e448784896fdfc6317c -
Trigger Event:
push
-
Statement type: