gjoseph92 / stackstac

Turn a STAC catalog into a dask-based xarray
https://stackstac.readthedocs.io
MIT License
238 stars 49 forks source link

RasterioIOError during .compute task #184

Closed jbbarre closed 1 year ago

jbbarre commented 1 year ago

hello, I encouter this problem trying to stack images in a xarray dataframe. The code is running on a local debian server (80 cp - 190 GB memory) . Here is part of the code where the problem occurs (you can recognize part of the geogif example). The items collection contains 10 images.

stack = stackstac.stack(items.item_collection(), bounds_latlon=bbox, epsg = 32620, resolution=30)
scl = stack.sel(band=["SCL"])
invalid = da.isin(scl, [0, 1, 2, 3, 8, 9, 10])
valid = stack.where(~invalid)
rgb = valid.sel(band=["B04", "B03", "B02"])

quarterly = rgb.resample(time="Q").median()
ts_local = quarterly.compute()

And the associated error. I'm not sure that this error is directly related to stack.stac. Should I look for answers with rasterio and Gdal ?


RasterioIOError                           Traceback (most recent call last)
File ~/miniconda3/envs/earthgif/lib/python3.10/site-packages/stackstac/rio_reader.py:387, in read()
    386 try:
--> 387     result = reader.read(
    388         window=window,
    389         masked=True,
    390         # ^ NOTE: we always do a masked array, so we can safely apply scales and offsets
    391         # without potentially altering pixels that should have been the ``fill_value``
    392         **kwargs,
    393     )
    394 except Exception as e:

File ~/miniconda3/envs/earthgif/lib/python3.10/site-packages/stackstac/rio_reader.py:227, in read()
    226 with self._env.read:
--> 227     return self.dataset.read(1, window=window, **kwargs)

File rasterio/_warp.pyx:1235, in rasterio._warp.WarpedVRTReaderBase.read()

File rasterio/_io.pyx:612, in rasterio._io.DatasetReaderBase.read()

File rasterio/_io.pyx:939, in rasterio._io.DatasetReaderBase._read()

RasterioIOError: Read or write failed. IReadBlock failed at X offset 0, Y offset 4: /vsicurl/https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/21/X/VK/2021/8/S2B_21XVK_20210802_2_L2A/B02.tif, band 1: IReadBlock failed at X offset 0, Y offset 0: TIFFReadEncodedTile() failed.```
jbbarre commented 1 year ago

It seems that it is something specific to aws servers. I did not succeed to solve this. I switched to Planetary to move forward.

RichardScottOZ commented 1 year ago

You can get this sort of error with multiple reads from the same file.