diff --git a/CHANGELOG.MD b/CHANGELOG.MD index fb7fa04..af47338 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). This project attempts to match the major and minor versions of [stactools](https://github.com/stac-utils/stactools) and increments the patch number as needed. +## [Unreleased] + +### Added + +- Add `eo:snow_cover` for L2A + ## [0.6.4] - 2024-04-04 ### Added diff --git a/examples/sentinel2-l2a-example/S2A_T07HFE_20190212T192646_L2A/S2A_T07HFE_20190212T192646_L2A.json b/examples/sentinel2-l2a-example/S2A_T07HFE_20190212T192646_L2A/S2A_T07HFE_20190212T192646_L2A.json index f369db5..f16e51c 100644 --- a/examples/sentinel2-l2a-example/S2A_T07HFE_20190212T192646_L2A/S2A_T07HFE_20190212T192646_L2A.json +++ b/examples/sentinel2-l2a-example/S2A_T07HFE_20190212T192646_L2A/S2A_T07HFE_20190212T192646_L2A.json @@ -21,6 +21,7 @@ "msi" ], "eo:cloud_cover": 51.580326, + "eo:snow_cover": 0.0, "sat:orbit_state": "descending", "sat:relative_orbit": 13, "proj:epsg": 32707, diff --git a/src/stactools/sentinel2/granule_metadata.py b/src/stactools/sentinel2/granule_metadata.py index f11f556..6928388 100644 --- a/src/stactools/sentinel2/granule_metadata.py +++ b/src/stactools/sentinel2/granule_metadata.py @@ -100,6 +100,13 @@ def cloudiness_percentage(self) -> float | None: self._image_content_node.find_text("CLOUDY_PIXEL_PERCENTAGE"), ) + @property + def snow_ice_percentage(self) -> float | None: + return map_opt( + float, + self._image_content_node.find_text("SNOW_ICE_PERCENTAGE"), + ) + @property def mean_solar_zenith(self) -> float | None: return map_opt( diff --git a/src/stactools/sentinel2/stac.py b/src/stactools/sentinel2/stac.py index 0d94262..8478f75 100644 --- a/src/stactools/sentinel2/stac.py +++ b/src/stactools/sentinel2/stac.py @@ -80,6 +80,7 @@ class Metadata: scene_id: str cloudiness_percentage: Optional[float] + snow_ice_percentage: Optional[float] extra_assets: dict[str, pystac.Asset] geometry: dict[str, Any] datetime: datetime @@ -170,6 +171,7 @@ def create_item( # Electro-Optical Extension eo = EOExtension.ext(item, add_if_missing=True) eo.cloud_cover = metadata.cloudiness_percentage + eo.snow_cover = metadata.snow_ice_percentage RasterExtension.add_to(item) # Satellite Extension @@ -588,6 +590,7 @@ def metadata_from_safe_manifest( image_media_type=product_metadata.image_media_type, image_paths=product_metadata.image_paths, cloudiness_percentage=granule_metadata.cloudiness_percentage, + snow_ice_percentage=granule_metadata.cloudiness_percentage, epsg=granule_metadata.epsg, proj_bbox=[round(v, COORD_ROUNDING) for v in granule_metadata.proj_bbox], resolution_to_shape=granule_metadata.resolution_to_shape, @@ -669,6 +672,7 @@ def metadata_from_granule_metadata( extra_assets=extra_assets, metadata_dict=metadata_dict, cloudiness_percentage=granule_metadata.cloudiness_percentage, + snow_ice_percentage=granule_metadata.snow_ice_percentage, epsg=granule_metadata.epsg, proj_bbox=granule_metadata.proj_bbox, resolution_to_shape=granule_metadata.resolution_to_shape, diff --git a/tests/test_metadata.py b/tests/test_metadata.py index ad79bae..b0e6c30 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -61,6 +61,7 @@ def test_parses_product_metadata_properties(self): self.assertEqual(s2_props[k], v) self.assertEqual(granule_metadata.cloudiness_percentage, 51.580326) + self.assertEqual(granule_metadata.snow_ice_percentage, 0.0) self.assertEqual( granule_metadata.processing_baseline, s2_props[f"{s2_prefix}:processing_baseline"],