I trying to follow some code on git which uses sentinel hub images code
I'm stuck with one part of the code which opens and reads a grayscale tif image which for some reason returns a rasterio IOerror.
with rasterio.open(img_path) as src:
gamma0 = src.read(1)
The error message is as follows:
rasterio.errors.RasterioIOError: Read or write failed. /home/vulcanadmin/landstat-sentinel-fusion-installation/landsat-sentinel-fusion/data/processed/sentinel-1/antananarivo/vv-gamma0.tif, band 1: IReadBlock failed at X offset 0, Y offset 0: TIFFReadEncodedStrip() failed.
I checked the image. It isn't corrupt, no issues opening it with gdal.
Read that it has do with setting a GDAL variable, VRT_SHARED_SOURCE=0. I'm trying to figure out how this variable should be set or if anyone has encountered a similar issue and found a resolution. I'm using a linux system so tried setting it as an environment variable export $VRT_SHARED_SOURCE=0
but that didn't work. Neither did it work with the following,
with rasterio.Env(VRT_SHARED_SOURCE=0):
with rasterio.open('vv-gamma0.tif') as src:
gamma0 = src.read(1)
Would appreciate any help. Thanks.
Best Answer
Managed to figure out the what was causing the issue after some troubleshooting. I'm using the gdal package from SNAP (Sentinel Application Platform) to run this code. There was a problem with the images i was saving through SNAP's graph processing tool. There was no error message generated but rasterio had trouble opening it. I'd missed the warning messages on the image.
Note the warning message through gdalinfo
I had missed setting the Linux shared environment variable after restarting the system. This resolved the error on my part.
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/admin/snap/bin