You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
especially when it comes to item_assets description, the key referring to bands are different.
Leading to the error message when trying to use stacchip Sentinel2Indexer with the second collection:
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
CellIn[12], line119foriteminitems_list[:10]:
10print(f"Working on {item}")
--->11indexer=Sentinel2Indexer(item).create_index()
12chipper=Chipper(indexer, assets=["image"])
14# Get first chip for the "image" asset keyFile [/srv/conda/envs/notebook/lib/python3.10/site-packages/stacchip/indexer.py:200](https://hub.staging.digitalearthpacific.org/srv/conda/envs/notebook/lib/python3.10/site-packages/stacchip/indexer.py#line=199), in ChipIndexer.create_index(self)197foryinrange(0, self.y_size):
198forxinrange(0, self.x_size):
-->200cloud_cover_percentage, nodata_percentage=self.get_stats(x, y)
202index["chipid"][counter] =f"{self.item.id}-{x}-{y}"203index["date"][counter] =self.item.datetime.date()
File [/srv/conda/envs/notebook/lib/python3.10/site-packages/stacchip/indexer.py:342](https://hub.staging.digitalearthpacific.org/srv/conda/envs/notebook/lib/python3.10/site-packages/stacchip/indexer.py#line=341), in Sentinel2Indexer.get_stats(self, x, y)336defget_stats(self, x: int, y: int) ->Tuple[float, float]:
337""" 338 Cloud and nodata percentage for a chip 339 340 Uses the SCL band to compute these values. 341 """-->342scl=self.scl[
343y*self.chip_size : (y+1) *self.chip_size,
344x*self.chip_size : (x+1) *self.chip_size,
345 ]
347cloud_percentage=int(np.isin(scl, self.scl_filter).sum()) [/](https://hub.staging.digitalearthpacific.org/) scl.size349nodata_percentage=np.sum(scl==self.nodata_value) [/](https://hub.staging.digitalearthpacific.org/) scl.sizeFile [/srv/conda/envs/notebook/lib/python3.10/functools.py:981](https://hub.staging.digitalearthpacific.org/srv/conda/envs/notebook/lib/python3.10/functools.py#line=980), in cached_property.__get__(self, instance, owner)979val=cache.get(self.attrname, _NOT_FOUND)
980ifvalis_NOT_FOUND:
-->981val=self.func(instance)
982try:
983cache[self.attrname] =valFile [/srv/conda/envs/notebook/lib/python3.10/site-packages/stacchip/indexer.py:331](https://hub.staging.digitalearthpacific.org/srv/conda/envs/notebook/lib/python3.10/site-packages/stacchip/indexer.py#line=330), in Sentinel2Indexer.scl(self)327""" 328 The Scene Classification (SCL) band data for the STAC item 329 """330print("Loading scl band")
-->331withrasterio.open(self.item.assets["scl"].href) assrc:
332returnsrc.read(out_shape=(1, *self.shape), resampling=Resampling.nearest)[
3330334 ]
KeyError: 'scl'
The text was updated successfully, but these errors were encountered:
I could help to fix this hardcoding the test of different Scene Classification band keys "scl" and "SCL" in this case but perhaps there is a cleaner way to do it.
This Sentinel 2 L2A collection does not seem to be supported.
Indeed, the model is slightly different:
https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a
https://planetarycomputer.microsoft.com/api/stac/v1/collections/sentinel-2-l2a
especially when it comes to
item_assets
description, the key referring to bands are different.Leading to the error message when trying to use stacchip Sentinel2Indexer with the second collection:
The text was updated successfully, but these errors were encountered: