<html 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:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:12.0pt">Aha, that resolved the issue, thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">thomas bonfort <thomas.bonfort@gmail.com><br>
<b>Date: </b>Wednesday, August 21, 2024 at 9:32</span><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span><span style="font-size:12.0pt;color:black">AM<br>
<b>To: </b>Justin Terry <Justin.Terry@wri.org><br>
<b>Cc: </b>Gdal Dev <gdal-dev@lists.osgeo.org><br>
<b>Subject: </b>Re: [gdal-dev] Overview resampling generating non-existant values<o:p></o:p></span></p>
</div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" align="left" width="100%" style="width:100.0%;background:revert!important;border:revert!important;bottom:revert!important;color:revert!important;direction:revert!important;display:revert!important;font-size:revert!important;height:revert!important;letter-spacing:revert!important;line-height:revert!important;margin:revert!important;opacity:revert!important;order:revert!important;outline:revert!important;overflow:revert!important;padding:revert!important;position:revert!important;tab-size:revert!important;table-layout:revert!important;text-align:revert!important;text-indent:revert!important;text-orientation:revert!important;text-overflow:revert!important;text-transform:revert!important;top:revert!important;vertical-align:revert!important;visibility:revert!important;white-space:revert!important;width:revert!important;word-break:revert!important;word-spacing:revert!important;writing-mode:revert!important;zoom:revert!important;border:0!important;display:table!important;width:100%!important;table-layout:fixed!important;border-collapse:seperate!important;float:none!important;border-spacing:0px 0px!important">
<tbody>
<tr style="background:revert!important;border:revert!important;bottom:revert!important;color:revert!important;direction:revert!important;display:revert!important;font-size:revert!important;height:revert!important;letter-spacing:revert!important;line-height:revert!important;margin:revert!important;opacity:revert!important;order:revert!important;outline:revert!important;overflow:revert!important;padding:revert!important;position:revert!important;tab-size:revert!important;table-layout:revert!important;text-align:revert!important;text-indent:revert!important;text-orientation:revert!important;text-overflow:revert!important;text-transform:revert!important;top:revert!important;vertical-align:revert!important;visibility:revert!important;white-space:revert!important;width:revert!important;word-break:revert!important;word-spacing:revert!important;writing-mode:revert!important;zoom:revert!important">
<td style="background:#A6A6A6;padding:0in 0in 0in 0in;background:revert!important;border:revert!important;bottom:revert!important;color:revert!important;direction:revert!important;display:revert!important;font-size:revert!important;height:revert!important;letter-spacing:revert!important;line-height:revert!important;margin:revert!important;opacity:revert!important;order:revert!important;outline:revert!important;overflow:revert!important;padding:revert!important;position:revert!important;tab-size:revert!important;table-layout:revert!important;text-align:revert!important;text-indent:revert!important;text-orientation:revert!important;text-overflow:revert!important;text-transform:revert!important;top:revert!important;vertical-align:revert!important;visibility:revert!important;white-space:revert!important;width:revert!important;word-break:revert!important;word-spacing:revert!important;writing-mode:revert!important;zoom:revert!important;padding:2px!important;background-color:#A6A6A6!important;width:0px!important">
</td>
<td width="100%" style="width:100.0%;background:#EAEAEA;padding:0in 0in 0in 0in;background:revert!important;border:revert!important;bottom:revert!important;color:revert!important;direction:revert!important;display:revert!important;font-size:revert!important;height:revert!important;letter-spacing:revert!important;line-height:revert!important;margin:revert!important;opacity:revert!important;order:revert!important;outline:revert!important;overflow:revert!important;padding:revert!important;position:revert!important;tab-size:revert!important;table-layout:revert!important;text-align:revert!important;text-indent:revert!important;text-orientation:revert!important;text-overflow:revert!important;text-transform:revert!important;top:revert!important;vertical-align:revert!important;visibility:revert!important;white-space:revert!important;width:revert!important;word-break:revert!important;word-spacing:revert!important;writing-mode:revert!important;zoom:revert!important;width:100%!important;background-color:#EAEAEA!important;padding:15px!important;font-size:12px!important;font-weight:normal!important;color:#212121!important;text-align:left!important;word-wrap:break-word!important">
<div>
<p class="MsoNormal" style="mso-element:frame;mso-element-frame-hspace:2.25pt;mso-element-wrap:around;mso-element-anchor-vertical:paragraph;mso-element-anchor-horizontal:column;mso-height-rule:exactly">
<span style="font-size:12.0pt;font-family:"Segoe UI",sans-serif;color:black">You don't often get email from thomas.bonfort@gmail.com.
<a href="https://aka.ms/LearnAboutSenderIdentification">Learn why this is important</a>
</span><span style="font-size:12.0pt;font-family:"Segoe UI",sans-serif"><o:p></o:p></span></p>
</div>
</td>
<td style="background:#EAEAEA;padding:0in 0in 0in 0in;background:revert!important;border:revert!important;bottom:revert!important;color:revert!important;direction:revert!important;display:revert!important;font-size:revert!important;height:revert!important;letter-spacing:revert!important;line-height:revert!important;margin:revert!important;opacity:revert!important;order:revert!important;outline:revert!important;overflow:revert!important;padding:revert!important;position:revert!important;tab-size:revert!important;table-layout:revert!important;text-align:revert!important;text-indent:revert!important;text-orientation:revert!important;text-overflow:revert!important;text-transform:revert!important;top:revert!important;vertical-align:revert!important;visibility:revert!important;white-space:revert!important;width:revert!important;word-break:revert!important;word-spacing:revert!important;writing-mode:revert!important;zoom:revert!important;width:75px!important;background-color:#EAEAEA!important;padding:5px!important;font-size:12px!important;font-weight:normal!important;color:#212121!important;text-align:left!important;word-wrap:break-word!important">
</td>
</tr>
</tbody>
</table>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">For COG format, you should use -co RESAMPLING=mode. gdalwarp's -r switch only applies to the full resolution warper resampling, not the overviews.
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">TB<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">Le mer. 21 août 2024, 18:09, Justin Terry via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> a écrit :<o:p></o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222;background:white">Hi,</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222"> </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222">I'm experiencing a strange issue I've never seen before where certain resampling methods that should only include values in the original dataset, like mode and nearest, are adding new
values in the overviews. </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222"> </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222">For example, the original raster contains the following values:</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222"> </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222">[0, 1, 2, 4, 5, 8, 9, 10, 16, 17, 18, 20, 21, 32, 33, 34, 36, 37, 40, 41, 42, 64, 65, 66, 68, 69, 72, 73, 74, 80, 81, 82, 84, 85]</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222"> </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222">I resample it using the following command:</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222"> </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222">gdalwarp dataset.tif dataset_cog.tif -of COG -co COMPRESS=LZW -r mode</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222"> </span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white">
<span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:#222222">And when I look at overviews, I start these values, especially as it downsamples further:<br>
<br>
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 90, 91]<br>
<br>
I saw the same if I tried it with nearest resampling. Maybe I'm misunderstanding, but I would think these resampling methods would retain the original values, and not interpolate any in-between values. <br>
<br>
I'm using GDAL version 3.9.1 on Mac M3 from Homebrew. <br>
<br>
Thanks,<br>
Justin</span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:12.0pt"> <o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt">_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></span></p>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>