<div dir="ltr"><div><div><div><div><div><div><div>Hi Eugenio,<br><br></div>I've created a sample processing model (attached), that works ok, except a small error in the result (decimals).<br><br></div>For instance:<br><br>



        
        
        
        
        
        



<table cellspacing="0" border="0">
        <colgroup width="122"></colgroup>
        <colgroup width="85"></colgroup>
        <colgroup width="122"></colgroup>
        <colgroup width="116"></colgroup>
        <tbody><tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center" height="17" bgcolor="#DDDDDD"><b>Raster</b></td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center" bgcolor="#DDDDDD"><b>ID</b></td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center" bgcolor="#DDDDDD"><b>Pixel value</b></td>
                <td align="left"><br></td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">Z_top_res</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center">a</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">1202,03510276</td>
                <td align="left"><br></td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">t_top_res</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center">b</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">53,6123428345</td>
                <td align="left"><br></td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">topo</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center">c1</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">-182,584899902</td>
                <td align="left"><br></td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">SAGA Result 1</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center">c</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">15,1783676147</td>
                <td align="left"><br></td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">SAGA Result 2</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center">d</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">31,9437332153</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="center" bgcolor="#DDDDDD"><b>Diff</b></td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">Expected Result 1</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left"><br></td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">15,1783679504</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">0,000000335741</td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left" height="17">Expected Result 2</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left"><br></td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">31,9740872222</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right">0,0303540069</td>
        </tr>
</tbody></table>



<br>



        
        
        
        
        
        



<table cellspacing="0" border="0">
        <colgroup width="85"></colgroup>
        <colgroup width="282"></colgroup>
        <tbody><tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" colspan="2" align="center" valign="middle" height="17" bgcolor="#DDDDDD"><b>Formula</b></td>
                </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right" height="17">1</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left">ifelse(c1>0,-(0.0065*c1-16),(0.0045*c1+16))</td>
        </tr>
        <tr>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="right" height="17">2</td>
                <td style="border-width:1px;border-style:solid;border-color:rgb(0,0,0)" align="left">ifelse(a<500,0,((b-c)/a)*1000)</td>
        </tr>
</tbody></table>



<br></div>Using SAGA GUI there is no error. <br><br></div>Could this be because of some roundings in the input / output? (I'm sending for the developer's list also).<br><br></div>Thanks!<br><br></div>Best regards,<br></div>Pedro Venâncio<br><div><div><div><br><div><div><br></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-31 10:56 GMT+01:00 Eugenio Trumpy <span dir="ltr"><<a href="mailto:frippe12573@hotmail.com" target="_blank">frippe12573@hotmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div id="m_82990895616978099divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" dir="ltr">
<p><br>
</p>
Hi Pedro,
<div><br>
</div>
<div>thank you very much to have tested the computation with my test data!</div>
<div>You are right, I checked again the computation and actually it works.</div>
<div><br>
</div>
<div>However, I was using Saga raster calculation in a processing modeler, and one of the layer I share with you</div>
<div>is the resulting from a previous computation. </div>
<div><br>
</div>
<div>In other word the raster layer c=temp_recal.tif comes from a previous computation (raster calculator):</div>
<div><span>ifelse(a>0,-(0.0065*a-16),(0.<wbr>0045*a+16))</span></div>
<div>where a is the layer attached, and hence c of the previous  formula is the resulting of this first computation.</div>
<div><br>
</div>
<div>E.<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div id="m_82990895616978099divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>Da:</b> Pedro Venâncio <<a href="mailto:pedrongvenancio@gmail.com" target="_blank">pedrongvenancio@gmail.com</a>><br>
<b>Inviato:</b> mercoledì 31 maggio 2017 11:37<span class=""><br>
<b>A:</b> frippe12573; qgis-user<br>
<b>Oggetto:</b> Re: [Qgis-user] Wrong result with Saga Raster calculator</span></font>
<div> </div>
</div><div><div class="h5">
<div>
<div dir="ltr">
<div>
<div>Hi Eugenio,<br>
<br>
</div>
The result with SAGA Raster Calculator seems ok here, on QGIS 2.18.9, SAGA 2.3.2, both from OSGeo4W64 (result attached).<br>
<br>
Z_top_res.tif have values from 724.403 to 1423.553, and so, the first condition is never true. Then, it always make ((b-c)/a)*1000, and the result seems ok to me.<br>
<br>
<br>
</div>
Pedro<br>
<div><br>
<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-05-31 10:19 GMT+01:00 frippe12573 <span dir="ltr"><<a href="mailto:frippe12573@hotmail.com" target="_blank">frippe12573@hotmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Paolo,<br>
<br>
the raster have the same size and origin.<br>
The pixels are precisely overlapped.<br>
<br>
I tried also r.mapcalc, but I got a worst result.<br>
Here the output of the log:<br>
<a href="https://pastebin.com/jNyyzHgf" rel="noreferrer" target="_blank">https://pastebin.com/jNyyzHgf</a><br>
<br>
E.<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Wrong-result-with-Saga-Raster-calculator-tp5322429p5322442.html" rel="noreferrer" target="_blank">
http://osgeo-org.1560.x6.nabbl<wbr>e.com/Wrong-result-with-Saga-<wbr>Raster-calculator-tp5322429p53<wbr>22442.html</a><br>
<span class="m_82990895616978099im m_82990895616978099HOEnZb">Sent from the QGIS - User mailing list archive at Nabble.com.<br>
</span>
<div class="m_82990895616978099HOEnZb">
<div class="m_82990895616978099h5">______________________________<wbr>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">
https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">
https://lists.osgeo.org/mailma<wbr>n/listinfo/qgis-user</a></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>
</div>
</div>

</blockquote></div><br></div>