<meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span></span></div><div><div>Hi,</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">I have never use the Qgis raster calculator via Python so I can't help there. What is the problem? Does Qgis crash?  If so, the rasters may be to big for the memory.   You mentioned the rasters were very big and that may be the problem.  I recommend you test the calculation with smaller rasters.  I think they are working for a solution for the big raster math.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Saga and gdal calculator may help.  Saga will probably try to load everything in memory an may crash.  Gdal is made to calculate very big rasters but layers must be in the same CRS and have the same pixel posting and extent.  You can use it direction in the Osgeo command prompt or via processing.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Nicolas</div><div id="AppleMailSignature"><br><br>Envoyé de mon iPad</div><div><br>Le 13 sept. 2016 à 05:42, ROMAN HG [via <a href="http://osgeo.org" target="_top" rel="nofollow" link="external">OSGeo.org</a>] <<a href="/user/SendEmail.jtp?type=node&node=5285530&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>> a écrit :<br><br></div><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' type="cite"><div>

        <div dir="ltr">Hi,<div><br></div><div>I'm trying to do raster calculations with big and multiple rasters. I am new to python, but I managed to use the QgsRasterCalculator algorithm to do the average of three rasters.</div><div><br></div><div>The problem comes when I introduce a forth layer and try to do a more complex equation:</div><div><br></div><div><blockquote style='border-left:2px solid #CCCCCC;padding:0 1em' style="border-left:2px solid #CCCCCC;padding:0 1em"><div><div>#calculating c4s ( [c1-c2]*[c0-c3] )</div><div><br></div><div>    #F1_30</div><div>A=processing.getObjectFromUri(path + "/F1_30c1.tif")</div><div>B=processing.getObjectFromUri(path + "/F1_c2.tif")</div><div>C=processing.getObjectFromUri(path + "/F1_30c0.tif")</div><div>D=processing.getObjectFromUri(path + "/F1_c3.tif")</div><div><br></div><div>entries=[]</div><div>rasA=QgsRasterCalculatorEntry()</div><div>rasA.ref='A@1'</div><div>rasA.raster=A</div><div>rasA.bandNumber=1</div><div>entries.append(rasA)</div><div><br></div><div>rasB=QgsRasterCalculatorEntry()</div><div>rasB.ref='B@1'</div><div>rasB.raster=B</div><div>rasB.bandNumber=1</div><div>entries.append(rasB)</div><div><br></div><div>rasC=QgsRasterCalculatorEntry()</div><div>rasC.ref='C@1'</div><div>rasC.raster=C</div><div>rasC.bandNumber=1</div><div>entries.append(rasC)</div><div><br></div><div>rasD=QgsRasterCalculatorEntry()</div><div>rasD.ref='D@1'</div><div>rasD.raster=D</div><div>rasD.bandNumber=1</div><div>entries.append(rasD)</div><div><br></div><div>F1_30c4=QgsRasterCalculator('(( A@1 - B@1 ) * ( C@1 - D@1 ))', path + '/F1_30c4.tif', 'GTiff', base.extent(), base.width(), base.height(), entries).processCalculation()</div></div><div><br></div></blockquote>I think that the problem is recognising the formula. I have tried it on the console doing several changes and it doesnt work.</div><div><br></div><div>Is it possible to do this operation with QgsRasterCalculator?? Or how can I use the gdal_calc algorithm or the saga raster calculator??<br><br></div><div><br></div><div>Thanks all</div></div>
<br>_______________________________________________
<br>Qgis-user mailing list
<br><a href="/user/SendEmail.jtp?type=node&node=5285491&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>
<br>List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_top" rel="nofollow" link="external">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_top" rel="nofollow" link="external">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>

        
        
        
        <br>
        <br>
        <hr noshade="noshade" size="1" color="#cccccc">
        <div style="color:#444; font: 12px tahoma,geneva,helvetica,arial,sans-serif;">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491.html" target="_top" rel="nofollow" link="external">http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491.html</a>
        </div>
        <div style="color:#666; font: 11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                To start a new topic under Quantum GIS - User, email <a href="/user/SendEmail.jtp?type=node&node=5285530&i=1" target="_top" rel="nofollow" link="external">[hidden email]</a> <br>
                To unsubscribe from Quantum GIS - User, <a href="" target="_top" rel="nofollow" link="external">click here</a>.<br>
                <a href="http://osgeo-org.1560.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_top" link="external">NAML</a>
        </div></div></blockquote></div>

        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Raster-calculator-script-failing-for-multiple-rasters-tp5285491p5285530.html">Re: Raster calculator script failing for multiple rasters</a><br/>
Sent from the <a href="http://osgeo-org.1560.x6.nabble.com/Quantum-GIS-User-f4125267.html">Quantum GIS - User mailing list archive</a> at Nabble.com.<br/>