<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I have no experience with gdal_calc.pv nor do I know about its
internals anything beside it being implemented with numpy. So I
comment this only from a general point of view.<br>
<br>
<div class="moz-cite-prefix">05.01.2016, 09:00, Avyav Kumar
kirjoitti:<br>
</div>
<blockquote
cite="mid:CAHOc4-3zhPG0vs8dSAcMLPOy2CbkJ0BbNVYYBmza6mWcAL6Vzg@mail.gmail.com"
type="cite">
<div dir="ltr">This is a rather interesting error, which is listed
here (<a moz-do-not-send="true"
href="https://trac.osgeo.org/gdal/ticket/5478">https://trac.osgeo.org/gdal/ticket/5478</a>).
While getting the intermediate calculations of the raster band
for A and B, I noticed the following -
<div><br>
</div>
<div>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. </div>
<div><br>
</div>
<div>
<div>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. </div>
</div>
<div><br>
</div>
<div>Logically, these should have the same value as there is no
difference between 20.0 and 20. </div>
</div>
</blockquote>
<br>
I would say that there is since 20.0 is a real number and 20 is an
integer. Now, depending on whether A and B are real or integer
valued, A*20 can be either real or integer valued and A*20.0 is real
valued, and A*20+B and A*20.0+B can be either real or integer
valued. Treating values as real or integer are quite different in
programming languages and also when storing them with raster
formats. Also, as you say below, integer values can easily flow
over.<br>
<br>
Best regards,<br>
<br>
Ari<br>
<br>
<blockquote
cite="mid:CAHOc4-3zhPG0vs8dSAcMLPOy2CbkJ0BbNVYYBmza6mWcAL6Vzg@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>However, as it is pointed out in the thread, running
gdalinfo -stats on them yields - </div>
<div><br>
</div>
<div>For --calc="A*20+B", the raster formed is a valid raster. </div>
<div><br>
</div>
<div>For --calc="A*20.0+B", the raster formed is invalid!<br>
</div>
<div><br>
</div>
<div>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? </div>
<div><br>
</div>
<div>Regards,</div>
<div><br>
</div>
<div>Avyav </div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
</blockquote>
<br>
</body>
</html>