python/BasicSentinelMerge broken due to missing SCL band
Closed this issue · 2 comments
ch-koehler commented
Using openeo
python client version 0.16.0,
sentinel2 = c.load_collection(
"SENTINEL2_L2A",
temporal_extent = ["2022-06-04", "2022-08-04"],
bands = ["B02", "B03", "B04","SCL"],
max_cloud_cover=75
)
in code block 3 from sentinel_merge.ipynb
runs into a
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[2], line 4
1 c=openeo.connect("openeo.cloud")
2 c.authenticate_oidc()
----> 4 sentinel2 = c.load_collection(
5 "SENTINEL2_L2A",
6 spatial_extent = {'west': 4.45, 'east': 4.70, 'south': 51.16, 'north': 51.22, 'crs': 'epsg:4326'},
7 temporal_extent = ["2022-06-04", "2022-08-04"],
8 bands = ["B02", "B03", "B04","SCL"],
9 max_cloud_cover=75
10 )
12 sentinel2 = sentinel2.process(
13 "mask_scl_dilation",
14 data=sentinel2,
(...)
20 # erosion_kernel_size=3
21 )
23 sentinel2 = sentinel2.aggregate_temporal_period("dekad",reducer="median")\
24 .apply_dimension(dimension="t", process="array_interpolate_linear")
File /opt/conda/lib/python3.10/site-packages/openeo/rest/connection.py:992, in Connection.load_collection(self, collection_id, spatial_extent, temporal_extent, bands, properties, max_cloud_cover, fetch_metadata)
968 def load_collection(
969 self,
970 collection_id: str,
(...)
976 fetch_metadata=True,
977 ) -> DataCube:
978 """
979 Load a DataCube by collection id.
980
(...)
990 added the ``max_cloud_cover`` argument.
991 """
--> 992 return DataCube.load_collection(
993 collection_id=collection_id, connection=self,
994 spatial_extent=spatial_extent, temporal_extent=temporal_extent, bands=bands, properties=properties,
995 max_cloud_cover=max_cloud_cover,
996 fetch_metadata=fetch_metadata,
997 )
File /opt/conda/lib/python3.10/site-packages/openeo/rest/datacube.py:148, in DataCube.load_collection(cls, collection_id, connection, spatial_extent, temporal_extent, bands, fetch_metadata, properties, max_cloud_cover)
146 if metadata:
147 bands = [b if isinstance(b, str) else metadata.band_dimension.band_name(b) for b in bands]
--> 148 metadata = metadata.filter_bands(bands)
149 else:
150 # Ensure minimal metadata with best effort band dimension guess (based on `bands` argument).
151 band_dimension = BandDimension("bands", bands=[Band(b, None, None) for b in bands])
File /opt/conda/lib/python3.10/site-packages/openeo/metadata.py:373, in CollectionMetadata.filter_bands(self, band_names)
367 """
368 Create new `CollectionMetadata` with filtered band dimension
369 :param band_names: list of band names/indices to keep
370 :return:
371 """
372 assert self.band_dimension
--> 373 return self._clone_and_update(dimensions=[
374 d.filter_bands(band_names) if isinstance(d, BandDimension) else d
375 for d in self._dimensions
376 ])
File /opt/conda/lib/python3.10/site-packages/openeo/metadata.py:374, in <listcomp>(.0)
367 """
368 Create new `CollectionMetadata` with filtered band dimension
369 :param band_names: list of band names/indices to keep
370 :return:
371 """
372 assert self.band_dimension
373 return self._clone_and_update(dimensions=[
--> 374 d.filter_bands(band_names) if isinstance(d, BandDimension) else d
375 for d in self._dimensions
376 ])
File /opt/conda/lib/python3.10/site-packages/openeo/metadata.py:149, in BandDimension.filter_bands(self, bands)
142 def filter_bands(self, bands: List[Union[int, str]]) -> 'BandDimension':
143 """
144 Construct new BandDimension with subset of bands,
145 based on given band indices or (common) names
146 """
147 return BandDimension(
148 name=self.name,
--> 149 bands=[self.bands[self.band_index(b)] for b in bands]
150 )
File /opt/conda/lib/python3.10/site-packages/openeo/metadata.py:149, in <listcomp>(.0)
142 def filter_bands(self, bands: List[Union[int, str]]) -> 'BandDimension':
143 """
144 Construct new BandDimension with subset of bands,
145 based on given band indices or (common) names
146 """
147 return BandDimension(
148 name=self.name,
--> 149 bands=[self.bands[self.band_index(b)] for b in bands]
150 )
File /opt/conda/lib/python3.10/site-packages/openeo/metadata.py:124, in BandDimension.band_index(self, band)
122 if any(aliases):
123 return aliases.index(True)
--> 124 raise ValueError("Invalid band name/index {b!r}. Valid names: {n!r}".format(b=band, n=band_names))
ValueError: Invalid band name/index 'SCL'. Valid names: ['B01', 'B02', 'B03', 'B04', 'B05', 'B06', 'B07', 'B08', 'B8A']
Seems the SCL band is not available (anymore?) on openeo.cloud
.
m-mohr commented
Thanks for the report, this is a temporary issue on openEO Platform. I made the devs aware of it and it should be solved soon. Sorry for the inconvenience.
cc @soxofaan
soxofaan commented
Issue has been fixed now on the development instance. I'm not sure yet how soon the fix will be available on production.
A workaround in the meantime is to use collection TERRASCOPE_S2_TOC_V2
instead of SENTINEL2_L2A