<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
span.Shkpostityyli20
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-ligatures:none;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language: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<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: GDALOverviewDataset(vrttest.vrt, this=000001CB3D728890) creation.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: Using GTiff driver<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: Computing area of interest: 26.8805, 63.2011, 27, 63.255<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Creating output file that is 3000P x 3000L.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,0,3000x3000 Dst=0,0,3000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">...10...20...30...40...50...60...70...80...90...100 - done.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language: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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: Using GTiff driver<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: Computing area of interest: 26.8805, 63.2011, 27, 63.255<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Creating output file that is 12000P x 12000L.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">WARP: Selecting overview level 1 for vrttest.vrt<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,0,1500x750 Dst=0,0,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">...10.GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,0,1500x750 Dst=6000,0,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">..20..GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,750,1500x750 Dst=0,3000,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">.30...GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,750,1500x750 Dst=6000,3000,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">40...50GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,1500,1500x750 Dst=0,6000,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">...60.GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,1500,1500x750 Dst=6000,6000,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">..70..GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=0,2250,1500x750 Dst=0,9000,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">.80...GDAL: GDALWarpKernel()::GWKNearestNoMasksOrDstDensityOnlyByte() Src=1500,2250,1500x750 Dst=6000,9000,6000x3000<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">90...100 - done.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">GDAL: Flushing dirty blocks: 0...10...20...30...40...50...60...70...80...90...100 - done.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language: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?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">The gdal_translate utility has also -ovr option
<a href="https://gdal.org/programs/gdal_translate.html#cmdoption-gdal_translate-ovr">
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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language: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.”<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language: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">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<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 <gdal-dev@lists.osgeo.org><br>
<b>Aihe:</b> [gdal-dev] Discrepancy in utilizing overviews with gdalwarp<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></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><o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></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:10.0pt">*.vrt.ovr</span></code>, while the second command operates noticeably slower, seemingly disregarding the overviews.<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>