#geospatial #metadata #geo #raster

stac

Rust library for the SpatioTemporal Asset Catalog (STAC) specification

17 unstable releases (5 breaking)

0.5.2 Oct 18, 2023
0.5.0 Jun 27, 2023
0.3.2 Feb 19, 2023
0.2.0 Dec 29, 2022
0.0.4 Mar 9, 2022

#60 in Science

Download history 71/week @ 2023-08-15 79/week @ 2023-08-22 47/week @ 2023-08-29 64/week @ 2023-09-05 67/week @ 2023-09-12 45/week @ 2023-09-19 107/week @ 2023-09-26 105/week @ 2023-10-03 32/week @ 2023-10-10 87/week @ 2023-10-17 39/week @ 2023-10-24 57/week @ 2023-10-31 49/week @ 2023-11-07 58/week @ 2023-11-14 62/week @ 2023-11-21 64/week @ 2023-11-28

239 downloads per month
Used in 5 crates

MIT/Apache

105KB
1.5K SLoC

stac

GitHub Workflow Status docs.rs Crates.io Crates.io Contributor Covenant

Rust implementation of the SpatioTemporal Asset Catalog (STAC) specification.

Usage

To use the library in your project:

[dependencies]
stac = "0.5"

Examples

use stac::Item;

// Creates an item from scratch.
let item = Item::new("an-id");

// Reads an item from the filesystem.
let item: Item = stac::read("data/simple-item.json").unwrap();

Please see the documentation for more usage examples.

Features

There are three opt-in features.

reqwest

reqwest enables blocking remote reads:

[dependencies]
stac = { version = "0.5", features = ["reqwest"]}

Then:

let href = "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json";
#[cfg(feature = "reqwest")]
let item: stac::Item = stac::read(href).unwrap();

If reqwest is not enabled, stac::read will throw an error if you try to read from a url.

let href = "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json";
#[cfg(not(feature = "reqwest"))]
let err = stac::read::<stac::Item>(href).unwrap_err();

For non-blocking IO, use the stac-async crate.

geo

To use geojson and geo to add some extra geo-enabled methods:

[dependencies]
stac = { version = "0.5", features = ["geo"] }

Then, you can set an item's geometry and bounding box at the same time:

#[cfg(feature = "geo")]
{
    use stac::Item;
    use geojson::{Geometry, Value};

    let geometry = Geometry::new(Value::Point(vec![
        -105.1, 41.1,
    ]));
    let mut item = Item::new("an-id");

    item.set_geometry(geometry).unwrap();
    assert!(item.bbox.is_some());
}

schemars

schemars allows for jsonschema generation from STAC objects. This is mostly useful for auto-generating OpenAPI documentation for STAC APIs.

[dependencies]
stac = { version = "0.5", features = ["schemars"]}

Dependencies

~4–17MB
~254K SLoC