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.1.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.1-cp39-abi3-win_amd64.whl (98.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

roaring_landmask-0.10.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (102.1 MB view details)

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

roaring_landmask-0.10.1-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (102.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

roaring_landmask-0.10.1-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.1.tar.gz.

File metadata

  • Download URL: roaring_landmask-0.10.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ba2ac75aaca1cd1cc19d1cf47991428ce0eb1225a6ea9de78caef2698ba8cf5f
MD5 f6330ae6676abd008f2222b5d4181432
BLAKE2b-256 b655cdd82d489d61e8c2af079c78f140db9ba3d557b337195eff29b3dd98c916

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.10.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6b4c9a2550af9f83ec54d77e580a11b426f50615d12bbe653f074c6f121ea52d
MD5 2cb4f5a1a5cba61c35b0e1d75a2cf82d
BLAKE2b-256 4aa308cf3170e87118259cc6f5620479eaa70da9ebbe47125a337d001c64fd8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.10.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 878734bdad14ba2fbc180be115051e3c8c70b280e19fda75d94baabcac775535
MD5 8b5e65aedf368cf3ab6c6857dea4e9f1
BLAKE2b-256 7c0ffe4665d07420346c03bcc2895ae2a2d24f37cef40ea9c1992048717dfe97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.10.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 35ae1053c5abf489d81474ed0b0de049a8674b84a9f42ac1af88e13a82a44673
MD5 a63dc933515a4dfdd7c8b14741d2491e
BLAKE2b-256 12ec4075e48d92bcbba6baaae1761f3208a6020ed9eda0cc2a6ab193b2948ac8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.10.1-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 828421b008f2ddafca9fb848c05113a80446fadca37279694736b97e033b9a24
MD5 f9ddc0f6a9c2ff66d0fa9198fb84228c
BLAKE2b-256 764f3d8dff04b0ed5156193a7ea0094eea67306aa869cee1c2f99cf41aa16515

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.10.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2369f0c438f6f80bfcec154af3d3473c60a2c521284c2c63928919d28b50c0e5
MD5 4bf794b68ca8ad05f869e4f161e709eb
BLAKE2b-256 33a6b3d24abcd7bf5c68816c8f55f803928b4e43557905ce15cd4b2d543fcf66

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