[gdal-dev] Overviews are not taken into account while reading with specified resampling method
Denis Rykov
rykovd at gmail.com
Thu Aug 27 10:30:14 PDT 2020
Hi Sean. I patched rasterio as you suggested and intermediate file now
looks like this (I'm trying now with a public dataset):
https://gist.github.com/drnextgis/3cbdbace7b5b8b80c3c6169b109bf9db
But when I read it with GDAL using non-nearest algorithm I'm getting
the following error:
>>> from osgeo import gdal>>> from osgeo.gdal import gdalconst>>> url = "/tmp/rasterio-boundless.vrt">>> ds = gdal.OpenEx(url)>>> image = ds.ReadAsArray(xoff=0, yoff=0, xsize=64, ysize=64, buf_xsize=10, buf_ysize=10, resample_alg=gdalconst.GRIORA_Cubic)
ERROR 4: /tmp/dummy.tif: No such file or directory
but with NearestNeighbour it works without error:
>>> from osgeo import gdal>>> from osgeo.gdal import gdalconst>>> url = "/tmp/rasterio-boundless.vrt">>> ds = gdal.OpenEx(url)>>> image = ds.ReadAsArray(xoff=0, yoff=0, xsize=64, ysize=64, buf_xsize=10, buf_ysize=10, resample_alg=gdalconst.GRIORA_NearestNeighbour)>>> image.shape(3, 10, 10)
I would be very appreciated if Even could explain why GDAL behaves
differently depending on resample_alg.
On Thu, Aug 27, 2020 at 6:39 PM Sean Gillies <sean at mapbox.com> wrote:
> Hi Denis, Even,
>
> On Thu, Aug 27, 2020 at 8:08 AM Even Rouault <even.rouault at spatialys.com>
> wrote:
>
>> On jeudi 27 août 2020 15:08:02 CEST Denis Rykov wrote:
>>
>> > I found the culprit. If remove this section from each band definition in
>>
>> > VRT file then everything works fine:
>>
>> >
>>
>> > <ComplexSource>
>>
>> > <SourceFilename relativeToVRT="1" shared="0">dummy.tif</SourceFilename>
>>
>> > <SourceBand>3</SourceBand>
>>
>> > <SourceProperties BlockXSize="128" BlockYSize="128"
>>
>> > RasterXSize="40961" RasterYSize="139265" dataType="Byte" />
>>
>> > <SrcRect xOff="0" xSize="1" yOff="0" ySize="1" />
>>
>> > <DstRect xOff="0" xSize="1" yOff="0" ySize="1" />
>>
>> > <ScaleRatio>0</ScaleRatio>
>>
>> > <ScaleOffset>0.0</ScaleOffset></ComplexSource
>>
>>
>>
>> I'm perhaps missing something, but the above snippet added by RasterIO
>> doesn't make sense to me. It just sets the pixel at (0,0) to 0. I bet it is
>> completely useless. It would make more sense to have xSize/ySize of DstRect
>> to cover the whole raster. And as <NoDataValue> is set on the
>> VRTRasterBand, this should be used to fill the target raster anyway.
>>
>>
>>
>> As far as why overviews of the original VRT aren't used is concerned, I'm
>> not sure why. I'd have expected it to work, but I must be missing something.
>>
>>
>>
>> Even
>>
>
> That's a rasterio bug: the background "dummy.tif" source should
> be <DstRect xOff="0" xSize="40961" yOff="0" ySize="139265" />. I'm working
> on a patch for this.
>
> This VRT background fill is different from nodata. The scale offset could
> be different from the nodata value. BTW, It takes advantage of GDAL
> shortcuts predicated on scale ratio. The "dummy.tif" file is never opened
> and doesn't even exist.
>
> --
> Sean Gillies
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200827/d1a52d3e/attachment-0001.html>
More information about the gdal-dev
mailing list