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.9.2.tar.gz (560.7 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.9.2-cp39-abi3-win_amd64.whl (98.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

roaring_landmask-0.9.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

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

roaring_landmask-0.9.2-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (5.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

roaring_landmask-0.9.2-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.9.2.tar.gz.

File metadata

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

File hashes

Hashes for roaring_landmask-0.9.2.tar.gz
Algorithm Hash digest
SHA256 64f8dcce7b1765a87b4448dfb3ced89d93a47b604116088757556a157f1c4c8a
MD5 28ba35da5d5fe192479cfda4d1a3a4f1
BLAKE2b-256 a36f1ee2ee4d40f26f171ff583b6a5ff8c53c83f7525bd8ea11b556be1520ec8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.9.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 50e3f3318eb3ca2b3d005f6044b70d4858148610b603bf301dd945b9f965f36f
MD5 d5250eb5ea40817bbb931d5be4026188
BLAKE2b-256 75c328059eb5335233f4da1ee6f139a3cd5bffb13b27dce057d665aa5341bf33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.9.2-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 fab3678f75bef27422aeab557a81320db1f1fffc351dd6b52a158c1a8921692c
MD5 33882b03e46e6422b4272ed7eacaab1b
BLAKE2b-256 ac69976edf91471c0ad50a5916c8d9f4dcaf62ed88cc2583319aaf35ca46f6cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.9.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f5ecb9853666888678c0129d74c5c86e5b46c89639a46ebfdec2b284f3dad96a
MD5 ee20e47a44a668aa1a6342448fe17ba6
BLAKE2b-256 8e511354d0d9a4765827634f154e25d1de83c94a91390a43047996b40bfc033e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.9.2-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e063bce89e8b1cd786114535be4bf2833b554a70c7bb86568f7c753d4b5c9c03
MD5 9eb071345744e5a61edd2ca11816ca15
BLAKE2b-256 7e4f8a4fa515f0775f6abec3e80cabae7270c558326750ca1ab85716716a9d67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for roaring_landmask-0.9.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6328c7143b6f57bc80b240d50780406069c27d846f42146abfd21622cbec49b3
MD5 f174e85a16ec5fd6f698b2fdbf1f70fb
BLAKE2b-256 b21920f09f9f38b55c262147b5bfdf7221c32bffb4ee458e631ede4ad06da2d4

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