#geospatial #raster #metadata #geo

stac

Rust编写的空间时间资产目录(STAC)规范库

23个不稳定版本 (8个破坏性更新)

0.8.0 2024年8月12日
0.7.2 2024年7月24日
0.7.0 2024年4月29日
0.5.2 2023年10月18日
0.0.4 2022年3月9日

#28 in 科学

Download history 23/week @ 2024-05-04 12/week @ 2024-05-11 39/week @ 2024-05-18 41/week @ 2024-05-25 25/week @ 2024-06-01 21/week @ 2024-06-08 20/week @ 2024-06-15 31/week @ 2024-06-22 131/week @ 2024-06-29 15/week @ 2024-07-06 36/week @ 2024-07-13 249/week @ 2024-07-20 179/week @ 2024-07-27 629/week @ 2024-08-03 192/week @ 2024-08-10 45/week @ 2024-08-17

每月下载量 1,080
用于 6 crates

MIT/Apache

1.5MB
3.5K SLoC

stac

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

Rust实现的空间时间资产目录(STAC)规范。

用法

要在项目中使用此库

[dependencies]
stac = "0.8"

示例

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();

有关更多用法示例,请参阅文档

功能

有几个可选功能。

reqwest

reqwest 允许阻塞远程读取

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

然后

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();

如果未启用 reqwest,则尝试从URL读取时,stac::read 将抛出错误。

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();

对于非阻塞IO,请使用 stac-async crate。

gdal

要使用 GDAL 创建具有投影和栅格波段信息的项目,您需要在您的系统上安装GDAL

[dependencies]
stac = { version = "0.8", features = ["gdal"] }

然后,从栅格创建的项目将包含投影和栅格扩展

#[cfg(feature = "gdal")]
{
    use stac::{extensions::{Raster, Projection}, Extensions, item::Builder};
    let item = Builder::new("an-id").asset("data", "assets/dataset_geo.tif").into_item().unwrap();
    assert!(item.has_extension::<Projection>());
    assert!(item.has_extension::<Raster>());
}

geo

使用 geo 添加一些额外的地理启用方法

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

然后,您可以同时设置项目的几何形状和边界框

#[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());
}

其他信息

此crate是stac-rs单体仓库的一部分,有关贡献和许可信息,请参阅其README。

依赖项

~4–18MB
~273K SLoC