[gdal-dev] gdal_calc.py gives different answers

Avyav Kumar avyavkumar at gmail.com
Mon Jan 4 23:00:08 PST 2016


This is a rather interesting error, which is listed here (
https://trac.osgeo.org/gdal/ticket/5478).  While getting the intermediate
calculations of the raster band for A and B, I noticed the following -

For --calc="A*20+B", the raster formed as the result of the addition of
A*20 and B is not equal to A*20 + B.

For --calc="A*20.0+B", the raster formed as the result of the addition of
A*20.0 and B is, in fact, equal to A*20 + B.

Logically, these should have the same value as there is no difference
between 20.0 and 20. However, as it is pointed out in the thread, running
gdalinfo -stats on them yields -

For --calc="A*20+B", the raster formed is a valid raster.

For --calc="A*20.0+B", the raster formed is invalid!

Hence, even though the intermediate calculation on the second --calc value
is correct, there is no valid output raster formed. Is it because the value
A*20 + B would have overshot the boundary values for 8-bit channel? Any
thoughts?

Regards,

Avyav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160105/40da6215/attachment.html>


More information about the gdal-dev mailing list