Crate roaring_landmask
source ·Expand description
§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).
§Usage
use roaring_landmask::RoaringLandmask;
let mask = RoaringLandmask::new(py).unwrap();
// Check some points on land
assert!(mask.contains(15., 65.6));
assert!(mask.contains(10., 60.0));
// Check a point in the ocean
assert!(!mask.contains(5., 65.6));
or in 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())
Re-exports§
pub use mask::RoaringMask;
pub use providers::LandmaskProvider;
pub use shapes::Shapes;