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.5.1.tar.gz (491.8 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.5.1-cp37-abi3-win_amd64.whl (38.7 MB view details)

Uploaded CPython 3.7+Windows x86-64

roaring_landmask-0.5.1-cp37-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (42.9 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.12+ x86-64

roaring_landmask-0.5.1-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl (43.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.12+ i686

roaring_landmask-0.5.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (78.0 MB view details)

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

roaring_landmask-0.5.1-cp37-abi3-macosx_10_7_x86_64.whl (38.9 MB view details)

Uploaded CPython 3.7+macOS 10.7+ x86-64

File details

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

File metadata

  • Download URL: roaring_landmask-0.5.1.tar.gz
  • Upload date:
  • Size: 491.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for roaring_landmask-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b28eb0d0c466c31aa935d91c88c6c491e721d4fc23b9da5a0f6d2b887a732c81
MD5 e1d2990e8ab9f3a86a48b611fef1b6ff
BLAKE2b-256 6afe7871861700e5c62db736dc2c562cb0097fcca7d5ccc49266a67bf2fdc0e5

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.5.1-cp37-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.5.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4a87e81a7411adb9bddf847383d0828afdc1204377f737c44092a35d746eb557
MD5 e265696011333b4fe84c09fb885f9753
BLAKE2b-256 1bf7f4e73ef8bb230c4c7ae875e4e743e5832f97e596f42dc5925e4052131ee0

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.5.1-cp37-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.5.1-cp37-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2bb866d0ddb26535f8b1aa88e52a7a29643860cdefc27dee1ddd3e8cd4f18e4f
MD5 d07a494d72e5f94a138cf5c40ed4838f
BLAKE2b-256 ef50dff3259c18531e0266a552c5da8bf1f8e4a6f3847a4d7568100bb20d05ba

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.5.1-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.5.1-cp37-abi3-manylinux_2_12_i686.manylinux2010_i686.whl
Algorithm Hash digest
SHA256 299df4a1676ddedefe6b91d602ad50916fcdbc97eff3725b2a00db8e0d3517c5
MD5 1c0bf61b5a335c9b8c9bb545ce1faca2
BLAKE2b-256 f85a9d799ab1187d278e8ca5439fde69267b6e2ee5536ce15855d01c2736b90f

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.5.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.5.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 bbf72dde714d634218fb6cc55d604351eae9beef8fe5d01e200dd5615c9c79af
MD5 be43ab6dd7a83a9121d823b939b3ca43
BLAKE2b-256 7b371c650a6f0ccb22e94c0e3bdc700d4a73c4cc1272030986d6dda42125bd6d

See more details on using hashes here.

File details

Details for the file roaring_landmask-0.5.1-cp37-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for roaring_landmask-0.5.1-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 ab7cb6c117ca6afb148cc30558a85d1797da1ebb405a3ce0e645f9843c1e62ad
MD5 7764c17c66c54f785bcab4ac6d52ff9d
BLAKE2b-256 3d7b157db38755d7d5773586c5e192c82cfad19c741773a7b82d2798188d582a

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