<div dir="ltr"><div>It's a single-pixel raster. The first two values printed are the cell center coordinates (0.5, 0.5), followed by the cell value (1).</div><div><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 9:46 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">Hi,<br>
<br>
I think I do not understand something simple, but how a byte type pixel can have one half as a value?<br>
<br>
0.5 0.5 1<br>
<br>
-Jukka Rahkonen-<br>
________________________________________<br>
Lähettäjä: gdal-dev <<a href="mailto:gdal-dev-bounces@lists.osgeo.org" target="_blank">gdal-dev-bounces@lists.osgeo.org</a>> käyttäjän Daniel Baston via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> puolesta<br>
Lähetetty: Torstai 13. marraskuuta 2025 16.40<br>
Vastaanottaja: Henry Walshaw <<a href="mailto:henry@floodmapp.com" target="_blank">henry@floodmapp.com</a>><br>
Kopio: <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a> <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>><br>
Aihe: Re: [gdal-dev] GDAL CLI converting to output datatype before performing calculation<br>
<br>
Hi Henry,The input values should not be rounded before doing the calculation. I get a correct result with both 3.12 and 3.11.5:$ gdal raster create --size 1,1 --burn 0.1 --output-data-type Float64 depth.tif$ gdal raster calc -i "A=depth.tif" -o footprint_b.tif --calc "A > 0 ? 1 : 0" --nodata none --ot Byte$ gdal raster convert footprint_b.tif --output-format XYZ /vsistdout/ERROR 6: Read or update mode not supported on /vsistdout0.5 0.5 1DanOn Thu, Nov 13, 2025 at 12:49 AM Henry Walshaw via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>> wrote:Hi all,In the docs for gdal raster calc (<a href="https://gdal.org/en/stable/programs/gdal_raster_calc.html#cmdoption-calc" rel="noreferrer" target="_blank">https://gdal.org/en/stable/programs/gdal_raster_calc.html#cmdoption-calc</a>) it statesInput rasters will be converted to 64-bit floating point numbers before performing calculations.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:<br>
gdal raster calc -i "A=depth.tif" -o footprint_b.tif --calc "A > 0 ? 1 : 0" --nodata none --ot Byte<br>
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?Regards,Henry​_______________________________________________gdal-dev mailing listgdal-dev@lists.osgeo.orghttps://<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote></div>