Skip to content

Commit

Permalink
feat: add eo extension
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Jun 21, 2024
1 parent c757fea commit 326d43c
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 1 deletion.
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

0 comments on commit 326d43c

Please sign in to comment.