<div dir="ltr"><div>Hi Henry,</div><div><br></div><div>The input values should not be rounded before doing the calculation. I get a correct result with both 3.12 and 3.11.5:</div><div><br></div><div>$ gdal raster create --size 1,1 --burn 0.1 --output-data-type Float64 depth.tif<br>$ gdal raster calc -i "A=depth.tif" -o footprint_b.tif --calc "A > 0 ? 1 : 0" --nodata none --ot Byte</div><div>$ gdal raster convert footprint_b.tif --output-format XYZ /vsistdout/<br>ERROR 6: Read or update mode not supported on /vsistdout<br>0.5 0.5 1<br><br></div><div>Dan</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Nov 13, 2025 at 12:49 AM Henry Walshaw via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</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>
<div>
<p style="margin-bottom:19.2px;margin-top:0px">Hi all,</p>
<p style="margin-bottom:19.2px;margin-top:0px">In the docs for <code style="background-color:rgba(175,184,193,0.2);border-radius:3px;font-family:Consolas,Inconsolata,Courier,monospace;font-size:16px;font-weight:550;margin-left:2.4px;margin-right:2.4px;padding-left:4.8px;padding-right:4.8px">
gdal raster calc</code> (<a href="https://_" target="_blank">https://gdal.org/en/stable/programs/gdal_raster_calc.html#cmdoption-calc</a>) it states</p>
<blockquote style="border-color:rgb(119,119,119) rgb(119,119,119) rgb(119,119,119) rgb(114,159,207);border-left:2px solid rgb(114,159,207);color:rgb(119,119,119);column-rule-color:rgb(119,119,119);margin:19.2px 0px;outline-color:rgb(119,119,119);padding-left:16px;padding-right:16px;quotes:none;text-decoration-color:rgb(119,119,119);text-emphasis-color:rgb(119,119,119)">
<p style="border-color:rgb(119,119,119);color:rgb(119,119,119);column-rule-color:rgb(119,119,119);margin-bottom:19.2px;margin-top:0px;outline-color:rgb(119,119,119);quotes:none;text-decoration-color:rgb(119,119,119);text-emphasis-color:rgb(119,119,119)">
Input rasters will be converted to 64-bit floating point numbers before performing calculations.</p>
</blockquote>
<p style="margin-bottom:19.2px;margin-top:0px">However I’ve found that when using an integer output datatype the base data is rounded to an integer before performing the calculation. e.g. converting a flood depth input.tif raster to a simple water / no
water footprint:</p>
<pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:16px;line-height:19.2px;margin-bottom:19.2px;margin-top:19.2px"><code style="background-color:rgb(255,255,255);border-width:1px;border-style:solid;border-color:rgb(204,204,204);border-radius:3px;display:block;font-family:Consolas,Inconsolata,Courier,monospace;font-size:16px;font-weight:550;line-height:19.2px;margin-left:2.4px;margin-right:2.4px;overflow:auto;padding:16px;white-space:pre-wrap">
gdal raster calc -i <span style="border-color:rgb(0,0,255);color:rgb(0,0,255);column-rule-color:rgb(0,0,255);font-family:Consolas,Inconsolata,Courier,monospace;font-size:16px;line-height:19.2px;outline-color:rgb(0,0,255);text-decoration-color:rgb(0,0,255);text-emphasis-color:rgb(0,0,255)">"A=depth.tif"</span> -o footprint_b.tif --calc <span style="border-color:rgb(0,0,255);color:rgb(0,0,255);column-rule-color:rgb(0,0,255);font-family:Consolas,Inconsolata,Courier,monospace;font-size:16px;line-height:19.2px;outline-color:rgb(0,0,255);text-decoration-color:rgb(0,0,255);text-emphasis-color:rgb(0,0,255)">"A > 0 ? 1 : 0"</span> --nodata none --ot Byte
</code></pre>
<p style="margin-bottom:19.2px;margin-top:0px">The expected result for a value of (say) 0.1 is 1, but in the above calculation it comes out as 0. Obviously I can leave the output datatype alone so it stays the same as the input’s 64-bit float, but it seems
unnecessary. Am I looking at a bug, or is this expected behaviour?</p>
<p style="margin-bottom:19.2px;margin-top:0px">Regards,</p>
<p style="margin-bottom:19.2px;margin-top:0px">Henry</p>
</div>
<div style="height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0px;padding:0px;margin:0px" aria-hidden="true" title="MDH:PHA+SGkgYWxsLDxicj48YnI+SW4gdGhlIGRvY3MgZm9yIGBnZGFsIHJh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VlbXMgdW5uZWNlc3NhcnkuIEFtIEkgbG9va2luZyBhdCBhIGJ1Zywgb3IgaXMgdGhpcyBleHBlY3RlZCBiZWhhdmlvdXI/PGJyPjwvcD48cD5SZWdhcmRzLDxicj48L3A+PHA+SGVucnk8L3A+PHVsIGNsYXNzPSJkcm9wZG93bi1tZW51IHRleHRjb21wbGV0ZS1kcm9wZG93biIgc3R5bGU9ImRpc3BsYXk6IG5vbmU7IHBvc2l0aW9uOiBhYnNvbHV0ZTsgei1pbmRleDogMTAwMDsiIGNvbnRlbnRlZGl0YWJsZT0iZmFsc2UiIHBvcG92ZXI9ImF1dG8iPjwvdWw+">
​</div>
</div>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>