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... 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 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 'donut' 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.4.tar.gz (16.3 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.4-cp310-abi3-win_amd64.whl (15.1 MB view details)

Uploaded CPython 3.10+Windows x86-64

mortie-0.6.4-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.4-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.4-cp310-abi3-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

mortie-0.6.4-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.4.tar.gz.

File metadata

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

File hashes

Hashes for mortie-0.6.4.tar.gz
Algorithm Hash digest
SHA256 38065c338e75dffee7fd0f253725555b989444a5c0496d0fbe6cf63770cfc54c
MD5 ea1910e7e72f8c5db0be9fa09f00838d
BLAKE2b-256 3cced6039fda4b6e2716bbf6c23cdd464eb1db48b2ad42bb611e6c56cb91c4dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.4.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.4-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: mortie-0.6.4-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.12

File hashes

Hashes for mortie-0.6.4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 094795315bfe30e9162ee6c5a9e4f35fed728c3583fee1616a6db7ab8f41d874
MD5 dc9b47b6e282603e7d924088fa632ea3
BLAKE2b-256 d03e028db6d0b75cac7114dd102f4e684d841f612fcc99b6af588e91fda971f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.4-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.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mortie-0.6.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9cceb6ddfa0281f46f3d386745490bc1a013f83385cf11173ed5c39200751c8e
MD5 12b97f3772062dcc5824eae013fe4053
BLAKE2b-256 25eb92daa565a33da543b4bffce06e40c3e62ae3cbe01957031985e1f57e53fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.4-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.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mortie-0.6.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b01a0608abb9993a4961798e763ca9533618f6bc6865ee09d6ab81e8c705ea44
MD5 5c4ed0c4178f6cfb9c8ee9c839855570
BLAKE2b-256 6004cdcfbd3c3d8571b312ac738a4c7fa8ccb5c2d54ea4aafbdd9b8250f547d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.4-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.4-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mortie-0.6.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d55dcf282eee1592852c93860ee3e86df1b5e704c5dcef2eb682bb0561be75ff
MD5 e714f1a5b1e200fc52cf986c0df8cc68
BLAKE2b-256 1c020704fdb38d633aeaced59a7db6c216d9b58b2c934d2e6b8ff9ab7a88a508

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.4-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.4-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mortie-0.6.4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 07f268488aea8fff4329cbd5599eeef00b5d37f49298ea8b15321d58dc444c29
MD5 7d715668d687434162b9ce37f5ddfc0a
BLAKE2b-256 69707b3af728d9e2fa0d0eaa1a5c6871a4674d90ee6c5b8e3205f6ac28c8cbb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mortie-0.6.4-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