#extension #stac #geospatial

stac-extensions

Manage STAC extensions (https://stac-extensions.github.io/)

1 unstable release

new 0.1.0 Jan 31, 2025

#644 in Science

MIT/Apache

1.5MB
5.5K SLoC

stac-extensions

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

Rudimentary support for STAC extensions.

Other info

This crate is part of the stac-rs monorepo, see its README for contributing and license information.


lib.rs:

Extensions describe how STAC can use extensions that extend the functionality of the core spec or add fields for specific domains.

Extensions can be published anywhere, although the preferred location for public extensions is in the GitHub stac-extensions organization. This crate currently supports only a few extensions, though we plan to add more as we find the time. See https://stac-extensions.github.io/ for the latest table of community extensions. This table below lists all stable extensions, as well as any other extensions that are supported by stac-rs:

Extension Maturity stac-rs supported version
Authentication Proposal v1.1.0
Electro-Optical Stable v1.1.0
File Info Stable n/a
Landsat Stable n/a
Projection Stable v1.1.0
Raster Candidate v1.1.0
Scientific Citation Stable n/a
View Geometry Stable n/a

Usage

[Item], [Collection], and [Catalog] all implement the [Extensions] trait, which provides methods to get, set, and remove extension information:

use stac::Item;
use stac_extensions::{Extensions, Projection, projection::Centroid};
let mut item: Item = stac::read("examples/extensions-collection/proj-example/proj-example.json").unwrap();
assert!(item.has_extension::<Projection>());

// Get extension information
let mut projection: Projection = item.extension().unwrap();
println!("code: {}", projection.code.as_ref().unwrap());

// Set extension information
projection.centroid = Some(Centroid { lat: 34.595302, lon: -101.344483 });
Extensions::set_extension(&mut item, projection).unwrap();

// Remove an extension
Extensions::remove_extension::<Projection>(&mut item);
assert!(!item.has_extension::<Projection>());

Dependencies

~5.5–7.5MB
~128K SLoC