<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello everyone,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I am using GDAL 2.4.1  with Python 3.6 to access rasters in Object Storage using /vsiswift. I need to open around 100 rasters, read their data and capture it in an array. I do not need to have them all available in memory, this is a sequential task , read one
 raster, delete dataset and continue with another one within a for loop.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Here is a fragment of my code:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span> <b>files = ['/vsiswift/spatial/sourceinput/Atlanta_nadir27_catid_1030010003472200/Pan-Sharpen/Pan-Sharpen_Atlanta_nadir27_catid_1030010003472200_732701_3725139.tif',<br>
</b></span>
<div><b>             '/vsiswift/spatial/sourceinput/Atlanta_nadir42_catid_10300100035D1B00/Pan-Sharpen/Pan-Sharpen_Atlanta_nadir42_catid_10300100035D1B00_732701_3725139.tif',<br>
</b></div>
<b><span>             '/vsiswift/spatial/sourceinput/Atlanta_nadir7_catid_1030010003D22F00/Pan-Sharpen/Pan-Sharpen_Atlanta_nadir7_catid_1030010003D22F00_732701_3725139.tif',</span></b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>              .</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>              .</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>              .</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b><span>             '/vsiswift/spatial/sourceinput/Atlanta_nadir42_catid_10300100035D1B00/Pan-Sharpen/Pan-Sharpen_Atlanta_nadir42_catid_10300100035D1B00_732701_3730989.tif'<br>
</span></b>
<div><b>             ]<br>
</b></div>
<b><span></span></b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b> for _file in tqdm(files[:]):</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b><span>    tileHdl = gdal.Open(_file, gdal.GA_ReadOnly)</span><br>
</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>    data = tileHdl.ReadAsArray()</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b><span></span>    del tileHDL<br>
</b></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
My problem is that, after reading 19 rasters, the 20th one returns a dataset in the Open operation , but returns 'None' when I try the 'ReadAsArray()'. The 20th raster is a valid one, if I move this "failing" raster to the first position in the loop it gets
 read successfully.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I did print gdal lastErrorMsg and got the following error: "band 4: IReadBlock failed at X offset 0, Y offset 0: TIFFReadEncodedStrip() failed"</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Has anyone else succeded in accessing multiple rasters in the same python program? Is this a known issue? Maybe I have a problem in my code?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Truly appreciate your help and time.<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Zazhil-ha<br>
</div>
</body>
</html>