[gdal-dev] Access window out of range error with standard utils

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Wed Dec 8 10:24:01 PST 2021


Thanks Even,

I've narrowed it down to the mask file. When I move it out of the way gdal_translate completes without error. Perhaps my optimization step of using nearblack on only the infrared band instead of all 4 is at fault?

I agree it's hard to troubleshoot when the examples are not self-contained! I wish I were free to share the source images. I can share the .msk file though: https://paste.c-net.org/StrapsMaple

(First time using this service. I know nothing about it excepting it was the 1st result when searching for "binary pastebin")


-Matt

From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> On Behalf Of Even Rouault
Sent: December 8, 2021 11:08 AM
To: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Access window out of range error with standard utils


Matt,

this is likely a rounding bug somewhere, but I couldn't reproduce with what you provided (with GDAL master and 3.3.2 on Linux). I had to fix a few hardcoded paths in the VRTs and create SPOT7_FiftyMileCkSixtyMileR_321_150cm_19Jun2015_utm7.tif and SPOT7_FiftyMileCkSixtyMileR_432_150cm_19Jun2015_utm7.tif with

gdal_create SPOT7_FiftyMileCkSixtyMileR_321_150cm_19Jun2015_utm7.tif -outsize 31918 34252 -bands 4 -co tiled=yes -co sparse_ok=yes
gdaladdo SPOT7_FiftyMileCkSixtyMileR_321_150cm_19Jun2015_utm7.tif --config SPARSE_OK_OVERVIEW YES       # SPARSE_OK_OVERVIEW only taken into account with GDAL master

I also create a .vrt.msk file with

gdal_create SPOT7_FiftyMileCkSixtyMileR_321_150cm_19Jun2015_utm7.vrt.msk -outsize 31912 34252 -co sparse_ok=yes -mo INTERNAL_MASK_FLAGS_1=2 -of gtiff
gdaladdo SPOT7_FiftyMileCkSixtyMileR_321_150cm_19Jun2015_utm7.vrt.msk --config SPARSE_OK_OVERVIEW YES

I may have missed something. It would help if your reproducer was self contained.

Even
Le 08/12/2021 à 18:35, Matt.Wilkie at yukon.ca<mailto:Matt.Wilkie at yukon.ca> a écrit :
Hello,

Why is gdal off by one for the access window? I'm using standard utilities, no custom code. This is only happening (so far) on one file out of dozens.

```
$ gdal_translate -co compress=zstd -co predictor=yes -co level=17 ^
 -co bigtiff=yes -of cog INFILE.rgb-nir.vrt OUTFILE.tif
Input file size is 31918, 34252
0.ERROR 5: Access window out of range in RasterIO().  Requested
(0,0) of size 250x268 on raster of 249x267.
```

This is one step of a process where I'm taking two 3-band jpeg-in-geotiff images, defining a nodata mask, and creating a final 4-band cloud geotiff. Preceding steps to this one are:

gdal_translate -b 1 RGB.tif  b-red.vrt
gdal_translate -b 2 RGB.tif  b-grn.vrt
gdal_translate -b 3 RGB.tif  b-blu.vrt
gdal_translate -b 1 432.tif  b-nir.vrt

gdalbuildvrt -separate INFILE.rgb-nir.vrt ^
  b-red.vrt b-grn.vrt b-blu.vrt b-nir.vrt

gdal_translate INFILE.rgb-nir.vrt xx-to-mask.tif
nearblack -setmask xx-to-mask.tif
move xx-mask.tif.msk INFILE.rgb-nir.vrt.msk
del xx-mask.tif

gdal_translate INFILE.rgb-nir.vrt OUTFILE.tif

(Edited for legibility, options used are left out)

Gdalinfo reports the size of each image are the same:

$ findstr "Size" *.gdal-info
RGB.b-blu.vrt.gdal-info:Size is 31918, 34252
RGB.b-blu.vrt.gdal-info:Pixel Size = (1.500000000000000,-1.500000000000000)
RGB.b-grn.vrt.gdal-info:Size is 31918, 34252
RGB.b-grn.vrt.gdal-info:Pixel Size = (1.500000000000000,-1.500000000000000)
RGB.b-red.vrt.gdal-info:Size is 31918, 34252
RGB.b-red.vrt.gdal-info:Pixel Size = (1.500000000000000,-1.500000000000000)
432.b-nir.vrt.gdal-info:Size is 31918, 34252
432.b-nir.vrt.gdal-info:Pixel Size = (1.500000000000000,-1.500000000000000)
INFILE.rgb-nir.vrt.gdal-info:Size is 31918, 34252
INFILE.rgb-nir.vrt.gdal-info:Pixel Size = (1.500000000000000,-1.500000000000000)
INFILE.rgb-nir.vrt.msk.gdal-info:Size is 31918, 34252

The source VRT and gdalinfo reports are attached.

GDAL 3.3.2, released 2021/09/01 via Qgis 3.22 on Windows 10.

Matt Wilkie
Geomatics Developer & Administrator
Environment | Technology, Innovation and Mapping
T 867-667-8133 | Yukon.ca<http://yukon.ca/>
Hours: 08:30-16:30, Mon-Wed: Office, Thu: Remote, Fri: Away.




_______________________________________________

gdal-dev mailing list

gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>

https://lists.osgeo.org/mailman/listinfo/gdal-dev

--

http://www.spatialys.com<https://imsva91-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=http%3a%2f%2fwww.spatialys.com&umid=B685D7CA-D2A6-5E05-A200-E0AFE3B43C72&auth=c132af8ee7c9d1278d61a701569070a095ce962e-45f9e6e44e2899ec331fad264f0287e272c8edd7>

My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211208/9829ad2e/attachment-0001.html>


More information about the gdal-dev mailing list