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.8.0.tar.gz (493.4 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.8.0-cp39-abi3-win_amd64.whl (39.2 MB view details)

Uploaded CPython 3.9+Windows x86-64

roaring_landmask-0.8.0-cp39-abi3-win32.whl (39.1 MB view details)

Uploaded CPython 3.9+Windows x86

roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_x86_64.whl (49.4 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_i686.whl (49.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_armv7l.whl (48.7 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_aarch64.whl (49.1 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

roaring_landmask-0.8.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (43.1 MB view details)

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

roaring_landmask-0.8.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (43.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

roaring_landmask-0.8.0-cp39-abi3-macosx_11_0_arm64.whl (39.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

roaring_landmask-0.8.0-cp39-abi3-macosx_10_12_x86_64.whl (38.9 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for roaring_landmask-0.8.0.tar.gz
Algorithm Hash digest
SHA256 2348f7f4e719ec43730d4863168b9b0e3126943b90f0c589204dd070a9288b52
MD5 037d4f76b6018c24c5b891508e522f64
BLAKE2b-256 cdb280090d7066f4daeaba0e1b40eac2169bcd669eb9c9d2ef5d031ffc5b3dd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e7eaf94543295eb14e85ee2837c324ae94754356f44f5238bcfdce2e501f2d81
MD5 d643e4d80d68f65fd1a3e4f28604bb1f
BLAKE2b-256 117715bba4f3704b28dc6c8a9be198f6991024420baf96cc95a06cb2645c540e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 0fb69edfa641aa9c7975ed0542014336470c978b1a91e520a47a0fa31caf6880
MD5 6baefaea7ad935f8da5d696a24ee4387
BLAKE2b-256 dafcb2d9f5881e014b89edfe443f263eab96677c1def1606aa25cfe82d46bcdc

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d55754a8119aa0a81d9e849b61bb4168062a2b370d4562d0384dfd7d0ceccc97
MD5 71722022dc71a8ba57f5d86cf2687969
BLAKE2b-256 f853cfd386d8fe19e76c02f6a4334729463b3c70e67f88348911133a7ccbdd37

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 f8c998f45ed74c3c9d563c1ef5942b373b880311908744ecc17ccb4e79bd869a
MD5 a8180369a09f9c1589f1b075a3de3869
BLAKE2b-256 0bacc3ace5528f5acf635c2247e1f0a64e266f461c5e5d35793b07162a686273

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 02aeca81923bd2a75386f01ebf75b39774c73bcd69effa44f6c15d64cd610641
MD5 1e0e5f35489624e9b40608ffd0889ab5
BLAKE2b-256 fc89abb2278729cde3302dca2a83dd78d564084da65152bf1c3edd7391871a65

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 0298c666acfb32ffe452d821ebfb7d87926287a17418e2483325107a2a4caa84
MD5 cc090030936e37fc0c3359b00e067d20
BLAKE2b-256 e8208fd7149fcb916fd3c232e359e71528e96a9c996eeda36778631ad2ff97d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 159e27f7b4f1b57f37ff18c17bcdabe4175adb105d63bcea4ab7246b102e5e28
MD5 c08ce0107f90df0d0b9587add1501841
BLAKE2b-256 abd636b8ebc317a111f635cc5a1f560d92b5446fc6a659ae06b3eeeaf8bbd1e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7a3fa32f6fe500c6d9a29596a26184f9be7ee8fc819dc8ebf63c35e5fbeecef6
MD5 c36f21e1141f9e17c1577c4591452d7c
BLAKE2b-256 5aa9e7051860fc20c001d25f6ed318c6c68ae84f35c3ff4242df2daa93f50bba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 930434be38ba57e9f49562bec16fba68ee77b2cefbde67170f48a1a0930ef938
MD5 6c4649e2a74a2fdbfdf73287ba1328f0
BLAKE2b-256 33c4eb297b7ee3f5820a0a27e1b1ec4f428840cdf4e0b26ce5ff9b2ef8468687

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.8.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.8.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a0ce6fa21255498d84e221a19fe2c71e16f023545879005d40f9b63de4af5f8d
MD5 9662cf5a97782cd1ca05260f26fd70df
BLAKE2b-256 cee47d75c4253129a5ae36c6cdbd5c579213f5258fff4e6913757eb04dc1e45e

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