Skip to main content

Crates.io Documentation PyPI Rust Python

The Roaring Landmask

Have you ever needed to know whether you are in the ocean or on land? And you need to know it fast? And you need to know it without using too much memory or too much disk? Then try the Roaring Landmask!

The roaring landmask is a Rust + Python package for quickly determining whether a point given in latitude and longitude is on land or not. A landmask is stored in a tree of Roaring Bitmaps. Points close to the shore might still be in the ocean, so a positive value is then checked against the vector shapes of the coastline.

(source)

The landmask is generated from the GSHHG shoreline database (Wessel, P., and W. H. F. Smith, A Global Self-consistent, Hierarchical, High-resolution Shoreline Database, J. Geophys. Res., 101, 8741-8743, 1996) and the OpenStreetMap (© OpenStreetMap).

An alternative is the opendrift-landmask-data, which is slightly faster, is pure Python, but requires more memory and disk space (memory-mapped 3.7Gb).

Performance

Microbenchmarks:

test tests::test_contains_in_ocean         ... bench:          24 ns/iter (+/- 0)
test tests::test_contains_on_land          ... bench:       3,795 ns/iter (+/- 214)

Many points, through Python:

------------------------------------------------------------------------------------------------------ benchmark: 5 tests -----------------------------------------------------------------------------------------------------
Name (time in us)                       Min                     Max                    Mean                StdDev                  Median                   IQR            Outliers           OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_landmask_many_par          34,335.6220 (>1000.0)   39,922.9660 (>1000.0)   36,167.6438 (>1000.0)  1,602.6359 (>1000.0)   35,658.2270 (>1000.0)  1,722.6990 (>1000.0)       9;1       27.6490 (0.00)         30           1
test_landmask_many             130,760.1480 (>1000.0)  131,155.3400 (>1000.0)  130,863.7110 (>1000.0)    137.1064 (598.03)   130,809.7410 (>1000.0)    135.3770 (>1000.0)       1;1        7.6415 (0.00)          8           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The parallel version is significantly faster, while the sequential version is slightly slower than the equivalent benchmark in opendrift-landmask-data, which uses about 120 ms.

Usage from Python

from roaring_landmask import RoaringLandmask

l = RoaringLandmask.new()
x = np.arange(-180, 180, .5)
y = np.arange(-90, 90, .5)

xx, yy = np.meshgrid(x,y)

print ("points:", len(xx.ravel()))
on_land = l.contains_many(xx.ravel(), yy.ravel())

Building & installing

Pre-built wheels are available on PyPI:

  1. pip install roaring-landmask

To build from source, you can use pip:

  1. pip install .

or maturin:

  1. Install maturin.

  2. Build and install

maturin build --release
pip install target/wheels/... # choose your whl

Metadata

Release files for roaring-landmask 0.11.0

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

Source distribution (sdist)

Source distribution for roaring-landmask 0.11.0
File Size Uploaded Provenance
roaring_landmask-0.11.0.tar.gz 571.1 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for roaring-landmask 0.11.0
File
roaring_landmask-0.11.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
roaring_landmask-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
roaring_landmask-0.11.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.whl CPython 3.9 abi3 Linux glibc 2.12+ x86-32 Details
roaring_landmask-0.11.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 397.0 MB

Release files / roaring_landmask-0.11.0.tar.gz

Download URL roaring_landmask-0.11.0.tar.gz
Size 571.1 kB
Tags Source
SHA-256 checksum
How to use checksums
551dd95d3c6b735ccea102b45bd0996b39581486a9934923265e87edfb3fdd15
BLAKE2b-256 checksum
How to use checksums
04b14c232188b2aa7e33f7b0876c8389c2275b563a715e6e10789067b39b32a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / roaring_landmask-0.11.0-cp39-abi3-win_amd64.whl

Download URL roaring_landmask-0.11.0-cp39-abi3-win_amd64.whl
Size 97.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
986093c3928ec10cbd41b87f522c530ab583a7e60f0788a1acca98e1c1341756
BLAKE2b-256 checksum
How to use checksums
2e4c54fd1a03a9facb49b4817f1fd79cf79dc6faefe378d62af789ff3b5ff751
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / roaring_landmask-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL roaring_landmask-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 100.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e11b1e180ce28e2366f5238aa261db2b2d68007ee72800c4eccc70330f4608dd
BLAKE2b-256 checksum
How to use checksums
a61a99419743511672a8a69db20f804499f48728282ded28dcf75917674e8f53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / roaring_landmask-0.11.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.whl

Download URL roaring_landmask-0.11.0-cp39-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Size 100.1 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-32 abi3
SHA-256 checksum
How to use checksums
c1283fd529f5fa4ae159b8d0396d84c14d22a7a909e8d8a663260d90d8bdfe2e
BLAKE2b-256 checksum
How to use checksums
9462fa2ff77aee4cb5fafce54b2f763b7cd5c6e569ddf520783ba2746230545d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / roaring_landmask-0.11.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL roaring_landmask-0.11.0-cp39-abi3-macosx_11_0_arm64.whl
Size 98.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ae5e1e72aa6468ad0c4fbf74595bae678ab3fd5efe19b6a41b1bbc800eba3ecb
BLAKE2b-256 checksum
How to use checksums
934ae285d7ef078d55eefd042b7a56c171d1833c41b44b3db3f8894b66f98825
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Security for roaring-landmask 0.11.0

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.

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