<div dir="ltr">Hi Sean. I patched rasterio as you suggested and intermediate file now looks like this (I'm trying now with a public dataset): <a href="https://gist.github.com/drnextgis/3cbdbace7b5b8b80c3c6169b109bf9db">https://gist.github.com/drnextgis/3cbdbace7b5b8b80c3c6169b109bf9db</a><div><br></div><div>But when I read it with GDAL using non-nearest algorithm I'm getting the following error:</div><div><br></div><div><pre style="color:rgb(0,0,0);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> <span style="color:rgb(128,0,0);font-weight:bold">from</span> osgeo <span style="color:rgb(128,0,0);font-weight:bold">import</span> gdal
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> <span style="color:rgb(128,0,0);font-weight:bold">from</span> osgeo<span style="color:rgb(128,128,48)">.</span>gdal <span style="color:rgb(128,0,0);font-weight:bold">import</span> gdalconst
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> url <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(0,0,230)">"/tmp/rasterio-boundless.vrt"</span>
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> ds <span style="color:rgb(128,128,48)">=</span> gdal<span style="color:rgb(128,128,48)">.</span>OpenEx<span style="color:rgb(128,128,48)">(</span>url<span style="color:rgb(128,128,48)">)</span>
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> image <span style="color:rgb(128,128,48)">=</span> ds<span style="color:rgb(128,128,48)">.</span>ReadAsArray<span style="color:rgb(128,128,48)">(</span>xoff<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,128,48)">,</span> yoff<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,128,48)">,</span> xsize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">64</span><span style="color:rgb(128,128,48)">,</span> ysize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">64</span><span style="color:rgb(128,128,48)">,</span> buf_xsize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> buf_ysize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> resample_alg<span style="color:rgb(128,128,48)">=</span>gdalconst<span style="color:rgb(128,128,48)">.</span>GRIORA_Cubic<span style="color:rgb(128,128,48)">)</span>
ERROR <span style="color:rgb(0,140,0)">4</span><span style="color:rgb(128,128,48)">:</span> <span style="color:rgb(68,170,221)">/</span>tmp<span style="color:rgb(68,170,221)">/</span>dummy<span style="color:rgb(128,128,48)">.</span>tif<span style="color:rgb(128,128,48)">:</span> No such <span style="color:rgb(64,0,0)">file</span> <span style="color:rgb(128,0,0);font-weight:bold">or</span> directory</pre>but with NearestNeighbour it works without error:</div><div><br></div><div><pre style="color:rgb(0,0,0);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> <span style="color:rgb(128,0,0);font-weight:bold">from</span> osgeo <span style="color:rgb(128,0,0);font-weight:bold">import</span> gdal
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> <span style="color:rgb(128,0,0);font-weight:bold">from</span> osgeo<span style="color:rgb(128,128,48)">.</span>gdal <span style="color:rgb(128,0,0);font-weight:bold">import</span> gdalconst
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> url <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(0,0,230)">"/tmp/rasterio-boundless.vrt"</span>
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> ds <span style="color:rgb(128,128,48)">=</span> gdal<span style="color:rgb(128,128,48)">.</span>OpenEx<span style="color:rgb(128,128,48)">(</span>url<span style="color:rgb(128,128,48)">)</span>
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> image <span style="color:rgb(128,128,48)">=</span> ds<span style="color:rgb(128,128,48)">.</span>ReadAsArray<span style="color:rgb(128,128,48)">(</span>xoff<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,128,48)">,</span> yoff<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,128,48)">,</span> xsize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">64</span><span style="color:rgb(128,128,48)">,</span> ysize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">64</span><span style="color:rgb(128,128,48)">,</span> buf_xsize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> buf_ysize<span style="color:rgb(128,128,48)">=</span><span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> resample_alg<span style="color:rgb(128,128,48)">=</span>gdalconst<span style="color:rgb(128,128,48)">.</span>GRIORA_NearestNeighbour<span style="color:rgb(128,128,48)">)</span>
<span style="color:rgb(68,170,221)">>></span><span style="color:rgb(68,170,221)">></span> image<span style="color:rgb(128,128,48)">.</span>shape
<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(0,140,0)">3</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(0,140,0)">10</span><span style="color:rgb(128,128,48)">)</span></pre>I would be very appreciated if Even could explain why GDAL behaves differently depending on resample_alg.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 27, 2020 at 6:39 PM Sean Gillies <<a href="mailto:sean@mapbox.com">sean@mapbox.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi Denis, Even,<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 27, 2020 at 8:08 AM Even Rouault <<a>even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div style="font-family:monospace;font-size:9pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px">On jeudi 27 août 2020 15:08:02 CEST Denis Rykov wrote:</p>
<p style="margin:0px;text-indent:0px">> I found the culprit. If remove this section from each band definition in</p>
<p style="margin:0px;text-indent:0px">> VRT file then everything works fine:</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> <ComplexSource></p>
<p style="margin:0px;text-indent:0px">>      <SourceFilename relativeToVRT="1" shared="0">dummy.tif</SourceFilename></p>
<p style="margin:0px;text-indent:0px">>      <SourceBand>3</SourceBand></p>
<p style="margin:0px;text-indent:0px">>      <SourceProperties BlockXSize="128" BlockYSize="128"</p>
<p style="margin:0px;text-indent:0px">> RasterXSize="40961" RasterYSize="139265" dataType="Byte" /></p>
<p style="margin:0px;text-indent:0px">>      <SrcRect xOff="0" xSize="1" yOff="0" ySize="1" /></p>
<p style="margin:0px;text-indent:0px">>      <DstRect xOff="0" xSize="1" yOff="0" ySize="1" /></p>
<p style="margin:0px;text-indent:0px">>      <ScaleRatio>0</ScaleRatio></p>
<p style="margin:0px;text-indent:0px">>      <ScaleOffset>0.0</ScaleOffset></ComplexSource</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">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.</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">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.</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Even</p></div></blockquote><div><br></div><div>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.</div><div><br></div><div>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. </div></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Sean Gillies</div></div></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a>gdal-dev@lists.osgeo.org</a><br>
<a rel="noreferrer">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote></div>