Skip to main content

A fast and limited-memory structure with a landmask based on GSHHG for determing whether a point on Earth is on land or in the ocean

Project description

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

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

roaring_landmask-0.10.0.tar.gz (561.5 kB view details)

Uploaded Source

Built Distributions

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

roaring_landmask-0.10.0-cp39-abi3-win_amd64.whl (98.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

roaring_landmask-0.10.0-cp39-abi3-win32.whl (97.9 MB view details)

Uploaded CPython 3.9+Windows x86

roaring_landmask-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB view details)

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

roaring_landmask-0.10.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (5.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

roaring_landmask-0.10.0-cp39-abi3-macosx_11_0_arm64.whl (98.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file roaring_landmask-0.10.0.tar.gz.

File metadata

  • Download URL: roaring_landmask-0.10.0.tar.gz
  • Upload date:
  • Size: 561.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for roaring_landmask-0.10.0.tar.gz
Algorithm Hash digest
SHA256 4801e3ca2be779553b9cca40cf64a6f1f2dae3e5dafb52a90b2ec9408ac9bad2
MD5 6e7baef4512f1682e98861267aa52345
BLAKE2b-256 9be59aa03a5e22218d0c3a7dfcffe84463410670bece2ea12f90cb4e7120737e

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.10.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.10.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d093b717938f7ea56a07831638d1b9de90edb455707f82b14490eb469bfe94bd
MD5 9c485cbd7e65bdc69005cff34ee56bd3
BLAKE2b-256 fe9c6ed777a9b31f62f6ce25fdc761fed21f05a76a8cb45c1f864c69e979a589

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.10.0-cp39-abi3-win32.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.10.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 b8bcb2f6b9586252c475830421c84618ddc6c5ee40b8e17c017401fa51ba9d3a
MD5 4558d4f36a0377f51f722e6e06e85383
BLAKE2b-256 7ce8fae840e75e20f44525439d04eedcc5e8fa00df2694fa9dffd2bc70a4c921

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d6603a3857d69f0379fbf7ef5c61d63790403cd9f7e2da808b2403e983fcfce
MD5 2639caafa7c8aea2262147166372acf6
BLAKE2b-256 03cc0e3124931e2427a3dd10fcc142b6a5facebe679dca90d82398a5c1681e50

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.10.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.10.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a709d9c59008e37afc33fc39dcfaab9fd0238a3fcc23cd5b58cdfb705bbe5a2d
MD5 90640c4807b0f2355d42c397d711b0d2
BLAKE2b-256 1d16e3a93604f57461e52839dd9ac64bf5be9c5d9b66fe7ed5de2377ba1c073b

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.10.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.10.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f582a8121bdf1dad00bafdf062245a6731e1b1b7a5862124885bfd4a8cea3abd
MD5 07a35c1cfc3487322ed984797bb54ade
BLAKE2b-256 4e830d7ddd52aaa28426c2538d6581b523f28455eaad38855c51a580f5bf95fa

See more details on using hashes here.

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