ValueError: Invalid band name/index 'SCL'. Valid names: ['B01', 'B02', 'B03', 'B04', 'B05'

s2_bands = eoconn.load_collection(
“SENTINEL2_L2A”,
temporal_extent=[startdate, enddate],
spatial_extent=dict(zip([“west”, “south”, “east”, “north”], bbox)),
bands=[“B04”, “B08”,“SCL”]
)
s2_bands = s2_bands.process(“mask_scl_dilation”, data=s2_bands, scl_band_name=“SCL”)

ValueError Traceback (most recent call last)
Cell In[8], line 1
----> 1 s2_bands = eoconn.load_collection(
2 “SENTINEL2_L2A”,
3 temporal_extent=[startdate, enddate],
4 spatial_extent=dict(zip([“west”, “south”, “east”, “north”], bbox)),
5 bands=[“B04”, “B08”,“SCL”]
6 )

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\rest\connection.py:1207, in Connection.load_collection(self, collection_id, spatial_extent, temporal_extent, bands, properties, max_cloud_cover, fetch_metadata)
1170 @openeo_process
1171 def load_collection(
1172 self,
(…)
1181 fetch_metadata: bool = True,
1182 ) → DataCube:
1183 “”"
1184 Load a DataCube by collection id.
1185
(…)
1205 Add :py:func:~openeo.rest.graph_building.collection_property support to properties argument.
1206 “”"
→ 1207 return DataCube.load_collection(
1208 collection_id=collection_id,
1209 connection=self,
1210 spatial_extent=spatial_extent,
1211 temporal_extent=temporal_extent,
1212 bands=bands,
1213 properties=properties,
1214 max_cloud_cover=max_cloud_cover,
1215 fetch_metadata=fetch_metadata,
1216 )

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\rest\datacube.py:201, in DataCube.load_collection(cls, collection_id, connection, spatial_extent, temporal_extent, bands, fetch_metadata, properties, max_cloud_cover)
199 if metadata:
200 bands = [b if isinstance(b, str) else metadata.band_dimension.band_name(b) for b in bands]
→ 201 metadata = metadata.filter_bands(bands)
202 arguments[‘bands’] = bands
204 if isinstance(properties, list):
205 # TODO: warn about items that are not CollectionProperty objects instead of silently dropping them.

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\metadata.py:307, in CubeMetadata.filter_bands(self, band_names)
300 “”"
301 Create new CubeMetadata with filtered band dimension
302 :param band_names: list of band names/indices to keep
303 :return:
304 “”"
305 assert self.band_dimension
306 return self._clone_and_update(
→ 307 dimensions=[d.filter_bands(band_names) if isinstance(d, BandDimension) else d for d in self._dimensions]
308 )

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\metadata.py:307, in (.0)
300 “”"
301 Create new CubeMetadata with filtered band dimension
302 :param band_names: list of band names/indices to keep
303 :return:
304 “”"
305 assert self.band_dimension
306 return self._clone_and_update(
→ 307 dimensions=[d.filter_bands(band_names) if isinstance(d, BandDimension) else d for d in self._dimensions]
308 )

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\metadata.py:172, in BandDimension.filter_bands(self, bands)
165 def filter_bands(self, bands: List[Union[int, str]]) → BandDimension:
166 “”"
167 Construct new BandDimension with subset of bands,
168 based on given band indices or (common) names
169 “”"
170 return BandDimension(
171 name=self.name,
→ 172 bands=[self.bands[self.band_index(b)] for b in bands]
173 )

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\metadata.py:172, in (.0)
165 def filter_bands(self, bands: List[Union[int, str]]) → BandDimension:
166 “”"
167 Construct new BandDimension with subset of bands,
168 based on given band indices or (common) names
169 “”"
170 return BandDimension(
171 name=self.name,
→ 172 bands=[self.bands[self.band_index(b)] for b in bands]
173 )

File C:\ProgramData\anaconda3\envs\OpenEO\lib\site-packages\openeo\metadata.py:147, in BandDimension.band_index(self, band)
145 if any(aliases):
146 return aliases.index(True)
→ 147 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’, ‘B09’]

I assume you are connecting to openeo.cloud (openEO Platform) here.
On openEO Platform the “SENTINEL2_L2A” collection indeed does not expose a “SCL” band.
Onlye these bands are available as mentioned in the error message:
[‘B01’, ‘B02’, ‘B03’, ‘B04’, ‘B05’, ‘B06’, ‘B07’, ‘B08’, ‘B8A’, ‘B09’]

If you connect to another openEO backend like https://openeo.dataspace.copernicus.eu/ you will find “SCL” in the “SENTINEL2_L2A” collection

@stefaan.lippens I’m having the same issue running the notebook developed together with VITO: openEO_photovoltaic/udf_inference/openeo_pv_farms_inference_udf.ipynb at main · clausmichele/openEO_photovoltaic · GitHub

When did this breaking change happen? Where was this mentioned?

The problem is that SENTINEL2_L2A is a federated collection, provided by both VITO/Terrascope and EODC. The aggregator (openeo.cloud) only exposes the common bands of both.

SCL is not available on EODC, so the aggregator does not expose that.

E.g. the SENTINEL2_L2A bands provided by Terrascope on the left and EODC on right:

I created a ticket about this problem in openeo-aggregator:

as a workaround for @chakra : if you want to reliably use the SCL band of SENTINEL2_L2A you could consider switching to another openEO backend like

  • openeo.dataspace.copernicus.eu (works with a different authentication system, so you have to register there separately)
  • openeo.vito.be (also supports EGI for login like openeo.cloud)

EDIT:
as discussed at Smarter merging of band listings in federated collections · Issue #147 · Open-EO/openeo-aggregator · GitHub we now also changed to config to exclude EODC for the SENTINEL2_L2A collection, so that all the usual bands (including SCL) are available again on openeo.cloud

1 Like