Rust implementation of the SpatioTemporal Asset Catalog (STAC) specification.
To use the library in your project:
toml
[dependencies]
stac = "0.5"
```rust 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.
There are three opt-in features.
reqwest
enables blocking remote reads:
toml
[dependencies]
stac = { version = "0.5", features = ["reqwest"]}
Then:
```rust let href = "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json";
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.
```rust let href = "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json";
let err = stac::read::
For non-blocking IO, use the stac-async crate.
To use geojson and geo to add some extra geo-enabled methods:
toml
[dependencies]
stac = { version = "0.5", features = ["geo"] }
Then, you can set an item's geometry and bounding box at the same time:
```rust
{ 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
allows for jsonschema generation from STAC objects.
This is mostly useful for auto-generating OpenAPI documentation for STAC APIs.
toml
[dependencies]
stac = { version = "0.5", features = ["schemars"]}