Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eo extension #271

Merged
merged 1 commit into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stac/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- `TryFrom<Feature>` and `TryInto<Feature>` for `Item` ([#255](https://github.com/stac-utils/stac-rs/pull/255))
- `wkb` feature and `GeoparquetItem` ([#260](https://github.com/stac-utils/stac-rs/pull/260), [#263](https://github.com/stac-utils/stac-rs/pull/263))
- Authentication extension ([#268](https://github.com/stac-utils/stac-rs/pull/268))
- Electro-Optical extension ([#271](https://github.com/stac-utils/stac-rs/pull/271))

### Fixed

Expand Down
150 changes: 150 additions & 0 deletions stac/examples/eo/item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.1.0/schema.json"
],
"type": "Feature",
"id": "20201211_223832_CS2",
"bbox": [
172.91173669923782,
1.3438851951615003,
172.95469614953714,
1.3690476620161975
],
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
172.91173669923782,
1.3438851951615003
],
[
172.95469614953714,
1.3438851951615003
],
[
172.95469614953714,
1.3690476620161975
],
[
172.91173669923782,
1.3690476620161975
],
[
172.91173669923782,
1.3438851951615003
]
]
]
},
"properties": {
"datetime": "2020-12-11T22:38:32.125Z",
"created": "2020-12-12T01:48:13.725Z",
"updated": "2020-12-12T01:48:13.725Z",
"platform": "cool_sat2",
"instruments": [
"cool_sensor_v1"
],
"gsd": 0.66,
"eo:cloud_cover": 1.2,
"eo:snow_cover": 0
},
"collection": "eo-collection",
"links": [
{
"rel": "root",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
},
{
"rel": "parent",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
},
{
"rel": "collection",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
}
],
"assets": {
"analytic": {
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2_analytic.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"title": "4-Band Analytic",
"roles": [
"data"
],
"eo:bands": [
{
"name": "band1",
"common_name": "blue",
"center_wavelength": 0.47,
"full_width_half_max": 0.07,
"solar_illumination": 1959.66
},
{
"name": "band2",
"common_name": "green",
"center_wavelength": 0.56,
"full_width_half_max": 0.08,
"solar_illumination": 1823.24
},
{
"name": "band3",
"common_name": "red",
"center_wavelength": 0.645,
"full_width_half_max": 0.09,
"solar_illumination": 1512.06
},
{
"name": "band4",
"common_name": "nir",
"center_wavelength": 0.8,
"full_width_half_max": 0.152,
"solar_illumination": 1041.63
}
]
},
"thumbnail": {
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.jpg",
"title": "Thumbnail",
"type": "image/png",
"roles": [
"thumbnail"
]
},
"visual": {
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"title": "3-Band Visual",
"roles": [
"visual"
],
"eo:bands": [
{
"name": "band3",
"common_name": "red",
"center_wavelength": 0.645,
"full_width_half_max": 0.09
},
{
"name": "band2",
"common_name": "green",
"center_wavelength": 0.56,
"full_width_half_max": 0.08
},
{
"name": "band1",
"common_name": "blue",
"center_wavelength": 0.47,
"full_width_half_max": 0.07
}
]
}
}
}
82 changes: 82 additions & 0 deletions stac/src/extensions/electro_optical.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//! The [electro-optical](https://github.com/stac-extensions/eo) extension.

use crate::Extension;
use serde::{Deserialize, Serialize};

/// EO data is considered to be data that represents a snapshot of the Earth for
/// a single date and time.
///
/// It could consist of multiple spectral bands in any part of the
/// electromagnetic spectrum. Examples of EO data include sensors with visible,
/// short-wave and mid-wave IR bands (e.g., the OLI instrument on Landsat-8),
/// long-wave IR bands (e.g. TIRS aboard Landsat-8).
#[derive(Debug, Serialize, Deserialize)]
pub struct ElectroOptical {
/// An array of available bands where each object is a [Band].
///
/// If given, requires at least one band.
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub bands: Vec<Band>,

/// Estimate of cloud cover, in %.
#[serde(skip_serializing_if = "Option::is_none")]
pub cloud_cover: Option<f64>,

/// Estimate of snow and ice cover, in %.
#[serde(skip_serializing_if = "Option::is_none")]
pub snow_cover: Option<f64>,
}

/// [Spectral
/// bands](https://www.sciencedirect.com/topics/earth-and-planetary-sciences/spectral-band)
/// in an [Asset](crate::Asset).
#[derive(Debug, Serialize, Deserialize)]
pub struct Band {
/// The name of the band (e.g., "B01", "B8", "band2", "red").
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,

/// The name commonly used to refer to the band to make it easier to search for bands across instruments.
///
/// See the list of [accepted common names](https://github.com/stac-extensions/eo#common-band-names).
#[serde(skip_serializing_if = "Option::is_none")]
pub common_name: Option<String>,

/// Description to fully explain the band.
///
/// [CommonMark 0.29](http://commonmark.org/) syntax MAY be used for rich text representation.
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,

/// The center wavelength of the band, in micrometers (μm).
#[serde(skip_serializing_if = "Option::is_none")]
pub center_wavelength: Option<f64>,

/// Full width at half maximum (FWHM).
///
/// The width of the band, as measured at half the maximum transmission, in
/// micrometers (μm).
#[serde(skip_serializing_if = "Option::is_none")]
pub full_width_half_max: Option<f64>,

/// The solar illumination of the band, as measured at half the maximum transmission, in W/m2/micrometers.
#[serde(skip_serializing_if = "Option::is_none")]
pub solar_illumination: Option<f64>,
}

impl Extension for ElectroOptical {
const IDENTIFIER: &'static str = "https://stac-extensions.github.io/eo/v1.1.0/schema.json";
const PREFIX: &'static str = "eo";
}

#[cfg(test)]
mod tests {
use super::ElectroOptical;
use crate::{Extensions, Item};

#[test]
fn item() {
let item: Item = crate::read("examples/eo/item.json").unwrap();
let _: ElectroOptical = item.extension().unwrap().unwrap();
}
}
3 changes: 2 additions & 1 deletion stac/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//! | Extension | Maturity | **stac-rs** supported version |
//! | -- | -- | -- |
//! | [Authentication](https://github.com/stac-extensions/authentication) | Proposal | v1.1.0 |
//! | [Electro-Optical](https://github.com/stac-extensions/eo) | Stable | n/a |
//! | [Electro-Optical](https://github.com/stac-extensions/eo) | Stable | v1.1.0 |
//! | [File Info](https://github.com/stac-extensions/file) | Stable | n/a |
//! | [Landsat](https://github.com/stac-extensions/landsat) | Stable | n/a |
//! | [Projection](https://github.com/stac-extensions/projection) | Stable | v1.1.0 |
Expand Down Expand Up @@ -44,6 +44,7 @@
//! ```

pub mod authentication;
pub mod electro_optical;
pub mod projection;
pub mod raster;

Expand Down