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 Actions Status

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).

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.7.2.tar.gz (494.9 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.7.2-cp38-abi3-win_amd64.whl (38.8 MB view details)

Uploaded CPython 3.8+Windows x86-64

roaring_landmask-0.7.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.7 MB view details)

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

roaring_landmask-0.7.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (43.7 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ i686

roaring_landmask-0.7.2-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (78.2 MB view details)

Uploaded CPython 3.8+macOS 10.9+ universal2 (ARM64, x86-64)macOS 10.9+ x86-64macOS 11.0+ ARM64

roaring_landmask-0.7.2-cp38-abi3-macosx_10_7_x86_64.whl (38.9 MB view details)

Uploaded CPython 3.8+macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: roaring_landmask-0.7.2.tar.gz
  • Upload date:
  • Size: 494.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for roaring_landmask-0.7.2.tar.gz
Algorithm Hash digest
SHA256 b1ee409ee29e2047ae5a4ca99cd194c4adc5b53efc854f608f51b192ff8d4aa5
MD5 e7742d0c7c3b16c791aff2c3a8bf8cf0
BLAKE2b-256 628f8b6b7b9d8823c392895c5a36a8fef5e7d9d0d20d3293a3db0f367cec5e15

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.7.2-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.7.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0d6889ca56d4057cc71eea6c36b0d98f7d2280a7d90fa66de420e03e425f0843
MD5 3b513fff1e7f51ffe97ae2afa779da94
BLAKE2b-256 67c5092ae526a415e3b4591e39b6ec76ab7f7f42a96028a41bcad9fa589171ad

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.7.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.7.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87b8fbf2ec54b5a51d4cf8d059a78df7ae637146a1932a757e4d64a23da5aa71
MD5 19da8422f839e0b8a2f283f5de9c6842
BLAKE2b-256 c871fd308a858ff883bd027e11cc687aff5d180b41c765fe0719f4e9bc6648a6

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.7.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.7.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 6c94948b7fbff3ad2b619e287b0006505961f9d8fee1bd2aee1ddf1deb0d94c2
MD5 5ad7480c4362dead4bccbe46173178f0
BLAKE2b-256 0bf4cc01101b755848a88cdee5360e7635607c3bcb47625d34866b932fb6898a

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.7.2-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.7.2-cp38-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 d95f41c0c4d1c8d6987e9f8dca11f35b31feb34de9fd2ca101f1cf2472925048
MD5 bc21944675d79b83c943fa0c1c2753e7
BLAKE2b-256 66248bc9b995fc0c74477529caa2c35a3d8337553aa28e27f17ebe78bc2ca592

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.7.2-cp38-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.7.2-cp38-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 87ad4dc61534dd1a13b3f187e6a55b1ce95cfcaea37b33b30e5549a5695a5538
MD5 f454d679bea91dad8e85797681c3994f
BLAKE2b-256 2909f7801eaa0190d9121cd62d37a47745c96f68e3cd05387d28084f24d051b3

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