Expand description
Rust implementation of the SpatioTemporal Asset Catalog (STAC) specification.
The SpatioTemporal Asset Catalog (STAC) specification provides a common language to describe a range of geospatial information, so it can more easily be indexed and discovered. A ‘spatiotemporal asset’ is any file that represents information about the earth captured in a certain space and time.
This is a Rust implementation of the specification. Similar projects in other languages include:
- Python: PySTAC
- Go: go-stac
- .NET: DotNetStac
- PHP: resto
§Data structures
STAC has three core data structures:
- Item is a GeoJSON Feature augmented with foreign members
- Catalog represents a logical group of other Catalogs, Collections, and Items
- Collection shares all fields with the
Catalog
(with different allowed values fortype
andstac_extensions
) and adds fields to describe the whole dataset and the included set ofItems
All three are provided as serde (de)serializable structures with public attributes.
Each structure provides a new
method that fills most of the object’s attributes with sensible defaults:
use stac::{Item, Catalog, Collection};
let item = Item::new("id");
let catalog = Catalog::new("id", "description");
let collection = Catalog::new("id", "description");
All attributes of STAC objects are accessible as public members:
use stac::{Item, Link};
let mut item = Item::new("id");
assert_eq!(item.id, "id");
assert!(item.geometry.is_none());
assert!(item.links.is_empty());
item.links.push(Link::new("an/href", "a-rel-type"));
§Value
A Value can represent any of the three core data structures, as well as an ItemCollection, akin to serde_json::Value:
use stac::{Value, Item};
let value = Value::Item(Item::new("an-id"));
Value implements most traits that are shared between the data structures, so users of this library can do work (e.g. migration) without needing to know what type of object the value represents:
use stac::{Value, Migrate, Version};
let value: Value = stac::read("examples/simple-item.json").unwrap();
let value = value.migrate(&Version::v1_1_0).unwrap();
§Input and output
Synchronous reads from the filesystem are supported via read:
let value: stac::Item = stac::read("examples/simple-item.json").unwrap();
If the reqwest feature is enabled, synchronous reads from urls are also supported:
#[cfg(feature = "reqwest")]
{
let url = "https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/simple-item.json";
let item: stac::Item = stac::read(url).unwrap();
}
To write, use write():
use stac::Format;
stac::write("an-id.json", stac::Item::new("an-id")).unwrap();
Enable the object-store
feature to get and put objects from e.g. AWS s3 (with the object-store-aws
feature) or from other backends (see features for a complete listing):
use stac::Item;
#[cfg(feature = "object-store")]
{
stac::io::put_opts("s3://bucket/item.json", Item::new("an-id"), [("foo", "bar")]).await.unwrap();
let item: Item = stac::io::get_opts("s3://bucket/item.json", [("foo", "bar")]).await.unwrap();
}
For more, see the documentation in the io module.
§Features
gdal
: read raster assets, see gdalgeo
: add some geo-enabled methods, see geogeoarrow
: read and write geoarrow, see geoarrowgeoparquet
: read and write geoparquet, see geoparquetgeoparquet-compression
: enable parquet compression
object-store
: get and put from object stores. Sub-features enable specific protocols:object-store-aws
object-store-azure
object-store-gcp
object-store-http
object-store-all
(enable them all)
reqwest
: get fromhttp
andhttps
urls when using read
Re-exports§
pub use extensions::Extension;
pub use extensions::Extensions;
pub use geoparquet::FromGeoparquet;
pub use geoparquet::IntoGeoparquet;
pub use io::read;
pub use io::write;
pub use item::FlatItem;
pub use item::Item;
pub use item::Properties;
pub use item::ITEM_TYPE;
pub use link::Link;
pub use link::Links;
Modules§
- Datetime utilities.
- Extensions describe how STAC can use extensions that extend the functionality of the core spec or add fields for specific domains.
- gdal
gdal
Functions that leverage GDAL. - geo
geo
Geometry utilities, enabled by thegeo
feature. - geoarrow
geoarrow
Convert between ItemCollection and Table. (experimental) - Read data from and write data to stac-geoparquet.
- Read and write STAC.
- STAC Items.
- Links.
- Media Types are a key element that enables STAC to be a rich source of information for clients.
Structs§
- An Asset is an object that contains a URI to data associated with the Item that can be downloaded or streamed.
- Bands are used to describe the available bands in a STAC entity or Asset.
- The STAC
Collection
Specification defines a set of common fields to describe a group of Items that share properties and metadata. - The object describes the spatio-temporal extents of the Collection.
- An item asset is an object that contains details about the datafiles that will be included in member items.
- A GeoJSON FeatureCollection of items.
- This object provides information about a provider.
- The object describes the spatial extents of the Collection.
- Statistics of all pixels in the band.
- The object describes the temporal extents of the Collection.
Enums§
- A bounding box.
- The data type gives information about the values in the file.
- Error enum for crate-specific errors.
- The format of STAC data.
- Enum for the four “types” of STAC values.
- An enum that can hold any STAC object type.
- A version of the STAC specification.
Constants§
- The type field for Catalogs.
- The type field for Collections.
- The type field for ItemCollections.
- The default STAC version of this library.
Traits§
- Trait implemented by anything that has assets.
- Trait for structures that have gettable and settable fields.
- Create a STAC object from JSON.
- Create a STAC object from newline-delimited JSON.
- Implemented by all three STAC objects, the Href trait allows getting and setting an object’s href.
- Migrates a STAC object from one version to another.
- Write a STAC object to JSON.
- Write a STAC object to newline-delimited JSON.
Functions§
- Utility function to deserialize the type field on an object.
- Utility function to serialize the type field on an object.
Type Aliases§
- Custom Result type for this crate.