<div dir="ltr">Thank you, Jukka, for reproducing the behavior and explaining the reason behind it!</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 10, 2024 at 9:19 AM Rahkonen Jukka <<a href="mailto:jukka.rahkonen@maanmittauslaitos.fi">jukka.rahkonen@maanmittauslaitos.fi</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 class="msg-3094747861169699419">
<div lang="FI" style="overflow-wrap: break-word;">
<div class="m_-3094747861169699419WordSection1">
<p class="MsoNormal"><span>Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Those two commands behave in quite different ways. With “-oo OVERVIEW_LEVEL=1” the output size is the size of the second overview. In my test case the original has 12000 x 12000 pixels
and the command creates a 3000 x 3000 sized output<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: GDALOverviewDataset(vrttest.vrt, this=000001CB3D728890) creation.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: Using GTiff driver<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: Computing area of interest: 26.8805, 63.2011, 27, 63.255<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Creating output file that is 3000P x 3000L.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">…<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,0,3000x3000 Dst=0,0,3000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">...10...20...30...40...50...60...70...80...90...100 - done.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">With -ovr 1 the output has the size of the full resolution image, 12000 x 12000 pixels, even the data is read from the 3000 x 3000 overview. The pixels will be upsampled.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: Using GTiff driver<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: Computing area of interest: 26.8805, 63.2011, 27, 63.255<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Creating output file that is 12000P x 12000L.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">WARP: Selecting overview level 1 for vrttest.vrt<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">…<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,0,1500x750 Dst=0,0,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">...10.GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,0,1500x750 Dst=6000,0,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">..20..GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,750,1500x750 Dst=0,3000,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">.30...GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,750,1500x750 Dst=6000,3000,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">40...50GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,1500,1500x750 Dst=0,6000,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">...60.GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,1500,1500x750 Dst=6000,6000,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">..70..GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,2250,1500x750 Dst=0,9000,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">.80...GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,2250,1500x750 Dst=6000,9000,6000x3000<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">90...100 - done.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">GDAL: Flushing dirty blocks: 0...10...20...30...40...50...60...70...80...90...100 - done.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The behavior is the same when using a TIFF with internal overviews as input instead of VRT. Obviously the -ovr option has been designed to force the use of some better-quality overview
as source data when warping yields a smaller, downsampled image. The forced upsampling does not make much sense to me. I wonder if gdalwarp should even allow that?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">The gdal_translate utility has also -ovr option
<a href="https://gdal.org/programs/gdal_translate.html#cmdoption-gdal_translate-ovr" target="_blank">
https://gdal.org/programs/gdal_translate.html#cmdoption-gdal_translate-ovr</a>. It behaves in a different way when it comes to the size of the output, but with gdal_translate it makes sense.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">“When -ovr is specified to an integer value, and none of -outsize and -tr is specified, the size of the overview will be used as the output size.”<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Maybe the thing to do is to improve the documentation of the gdalwarp option
<a href="https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-ovr" target="_blank">https://gdal.org/programs/gdalwarp.html#cmdoption-gdalwarp-ovr</a> and mention that this option does not have on effect on the size of the output.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> gdal-dev <<a href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank">gdal-dev-bounces@lists.osgeo.org</a>>
<b>Puolesta </b>Denis Rykov via gdal-dev<br>
<b>Lähetetty:</b> maanantai 10. kesäkuuta 2024 2.27<br>
<b>Vastaanottaja:</b> gdal dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
<b>Aihe:</b> [gdal-dev] Discrepancy in utilizing overviews with gdalwarp<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">I'd anticipate that both commands would yield the same outcome:<br>
<br>
<span style="font-family:"Courier New"">$ gdalwarp -oo OVERVIEW_LEVEL=1 -dstalpha input.vrt ovr1.tif<br>
$ gdalwarp -ovr 1 -dstalpha input.vrt ovr1.tif</span><u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">However, the reality is different. The first command behaves as intended, utilizing overviews from
<code><span style="font-size:10pt">*.vrt.ovr</span></code>, while the second command operates noticeably slower, seemingly disregarding the overviews.<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div></blockquote></div>