<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div class="markdown-here-wrapper">
<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-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-end-end-radius: 3px; border-end-start-radius: 3px; border-start-end-radius: 3px; border-start-start-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 16px; font-weight: 550; margin-left: 2.4px; margin-right: 2.4px; padding-inline: 4.8px; padding-left: 4.8px; padding-right: 4.8px; white-space-collapse: preserve;">
gdal raster calc</code> (<a href="https://_">https://gdal.org/en/stable/programs/gdal_raster_calc.html#cmdoption-calc</a>) it states</p>
<blockquote style="border-block-color: rgb(119, 119, 119); border-bottom-color: rgb(119, 119, 119); border-inline-color: rgb(114, 159, 207) rgb(119, 119, 119); border-inline-start: 2px solid rgb(114, 159, 207); border-left: 2px solid rgb(114, 159, 207); border-right-color: rgb(119, 119, 119); border-top-color: rgb(119, 119, 119); color: rgb(119, 119, 119); column-rule-color: rgb(119, 119, 119); margin: 19.2px 0px; outline-color: rgb(119, 119, 119); padding-inline: 16px; 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-block-color: rgb(119, 119, 119); border-bottom-color: rgb(119, 119, 119); border-inline-color: rgb(119, 119, 119); border-left-color: rgb(119, 119, 119); border-right-color: rgb(119, 119, 119); border-top-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 class="hljs language-bash" style="background-color: rgb(255, 255, 255); border-block: 1px solid rgb(204, 204, 204); border-bottom: 1px solid rgb(204, 204, 204); border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-end-end-radius: 3px; border-end-start-radius: 3px; border-inline: 1px solid rgb(204, 204, 204); border-left: 1px solid rgb(204, 204, 204); border-right: 1px solid rgb(204, 204, 204); border-start-end-radius: 3px; border-start-start-radius: 3px; border-top: 1px solid rgb(204, 204, 204); border-top-left-radius: 3px; border-top-right-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-block: auto; overflow-inline: auto; overflow: auto; padding-block: 16px; padding-bottom: 16px; padding-inline: 16px; padding-left: 16px; padding-right: 16px; padding-top: 16px; white-space: pre;">
gdal raster calc -i <span class="hljs-string" style="border-block-color: rgb(0, 0, 255); border-bottom-color: rgb(0, 0, 255); border-inline-color: rgb(0, 0, 255); border-left-color: rgb(0, 0, 255); border-right-color: rgb(0, 0, 255); border-top-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 class="hljs-string" style="border-block-color: rgb(0, 0, 255); border-bottom-color: rgb(0, 0, 255); border-inline-color: rgb(0, 0, 255); border-left-color: rgb(0, 0, 255); border-right-color: rgb(0, 0, 255); border-top-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 class="mdhr-raw" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0;padding:0;margin:0;" aria-hidden="true" title="MDH:PHA+SGkgYWxsLDxicj48YnI+SW4gdGhlIGRvY3MgZm9yIGBnZGFsIHJhc3RlciBjYWxjYCAoW2h0dHBzOi8vZ2RhbC5vcmcvZW4vc3RhYmxlL3Byb2dyYW1zL2dkYWxfcmFzdGVyX2NhbGMuaHRtbCNjbWRvcHRpb24tY2FsY10oXykpIGl0IHN0YXRlczxicj48YnI+Jmd0OyBJbnB1dCByYXN0ZXJzIHdpbGwgYmUgY29udmVydGVkIHRvIDY0LWJpdCBmbG9hdGluZyBwb2ludCBudW1iZXJzIGJlZm9yZSBwZXJmb3JtaW5nIGNhbGN1bGF0aW9ucy48YnI+PGJyPkhvd2V2ZXIgSeKAmXZlIGZvdW5kIHRoYXQgd2hlbiB1c2luZyBhbiBpbnRlZ2VyIG91dHB1dCBkYXRhdHlwZSB0aGUgYmFzZSBkYXRhIGlzIHJvdW5kZWQgdG8gYW4gaW50ZWdlciBiZWZvcmUgcGVyZm9ybWluZyB0aGUgY2FsY3VsYXRpb24uIGUuZy4gY29udmVydGluZyBhIGZsb29kIGRlcHRoIGlucHV0LnRpZiByYXN0ZXIgdG8gYSBzaW1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