Skip to main content

Morton numbering and indexing for healpix grids

Project description

mortie

Tests CodSpeed codecov PyPI version Python 3.10+ CodSpeed Badge

Morty using 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 capturing edge cells missed by sparse vertex sampling (e.g., near HEALPix pole holes).

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 completely cover a polygon defined by lat/lon vertices. The algorithm builds a contiguous boundary via great-circle interpolation, classifies inner/outer buffer cells using connected components + point-in-polygon testing, then recursively fills the interior.

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]

# Get all morton cells covering the polygon at order 6
cells = mortie.morton_coverage(lats, lons, order=6)

The function handles concave polygons, antimeridian-crossing polygons, and polar regions. Polygon holes are not yet supported.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mortie-0.6.3.tar.gz (16.7 MB view details)

Uploaded Source

Built Distributions

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

mortie-0.6.3-cp310-abi3-win_amd64.whl (15.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

mortie-0.6.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

mortie-0.6.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (15.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

mortie-0.6.3-cp310-abi3-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

mortie-0.6.3-cp310-abi3-macosx_10_12_x86_64.whl (15.1 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file mortie-0.6.3.tar.gz.

File metadata

  • Download URL: mortie-0.6.3.tar.gz
  • Upload date:
  • Size: 16.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mortie-0.6.3.tar.gz
Algorithm Hash digest
SHA256 ca00a54758d2ac47356cf0f37acc8175b24bd033d39f408daf7a8d82c235f99c
MD5 45ed8bc4ffc481e6bf0af78fbb950cd6
BLAKE2b-256 027dd783ec2f0d3f045f529cf91dc72249186ac2d9df09aff225cc04ae45f02d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.3.tar.gz:

Publisher: build-wheels.yml on espg/mortie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mortie-0.6.3-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: mortie-0.6.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 15.1 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mortie-0.6.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dfb5cfe9f8ff0c5e56629f6abf92f64ca74f628c5b63e66b04a01d738315129a
MD5 35c715a54e723815f6340d6565452305
BLAKE2b-256 e97e4c99c5c5e5dd6e95abf78e0150b4736e6b994a419d7b42f9920e44979ea6

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.3-cp310-abi3-win_amd64.whl:

Publisher: build-wheels.yml on espg/mortie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mortie-0.6.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mortie-0.6.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dda666a5e705d2ab48e56e8ee02919e00f8117482242b022899901835c77b97e
MD5 0d4e745134a5fdaf66cb32a58df709cd
BLAKE2b-256 7bc4a4c4c55b68cde2e2fb2421e4518dc678e2c70a5392d570be3afb37cd30d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-wheels.yml on espg/mortie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mortie-0.6.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mortie-0.6.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ec2c4f933d301ec00d9ea2bf9a39527bbf8eb0ad6e4916102745be39e64514f1
MD5 cf755f9ac0c75e86ff3c69918bde6e89
BLAKE2b-256 4f73728a8848700ee4b49d9610d5fd8b58ba838c30eab35ebfa0b92258aa8f3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: build-wheels.yml on espg/mortie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mortie-0.6.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mortie-0.6.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4bb906d0dd21470e2011bdc7a5585b1cc51e55211ab12c8a6a382603c2b1cba5
MD5 c6ab0c15eef2f3434e9a064bfc8d9847
BLAKE2b-256 431f0a41d60c39e4886c8764930404092f11f757059c7fe183880039295e42f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on espg/mortie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mortie-0.6.3-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mortie-0.6.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 97d64196bab7ed07d1553d83cb98ff5c4979d1e191e0c77f71d44e62565f498e
MD5 e83a8e81dcd4b13bc46f04387dd9919a
BLAKE2b-256 32289e4f3e65ee479dcdf9e7f41deb02ba2b87a431e6e0dc98280ff4a9e1d16d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.3-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: build-wheels.yml on espg/mortie

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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