<div dir="ltr">please give a try to this preliminary PR that should fix the use of raster calculator in the modeler<div><br></div><div><a href="https://github.com/qgis/QGIS/pull/7396">https://github.com/qgis/QGIS/pull/7396</a><div><br clear="all"><div><div dir="ltr" class="gmail_signature">Luigi Pirelli<br><br>**************************************************************************************************<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS 2nd Edition:<br>* <a href="https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition" target="_blank">https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition</a><br>* Hire me: <a href="http://goo.gl/BYRQKg" target="_blank">http://goo.gl/BYRQKg</a><br>**************************************************************************************************</div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 9 Jul 2018 at 11:02, Luigi Pirelli <<a href="mailto:luipir@gmail.com">luipir@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi <a class="gmail_plusreply" id="m_5988072846211154521m_6067105776945187557gmail-plusReplyChip-2" href="mailto:rudivs@gmail.com" target="_blank">@Rudi von Staden</a> , <a class="gmail_plusreply" id="m_5988072846211154521m_6067105776945187557gmail-plusReplyChip-1" href="mailto:nyall.dawson@gmail.com" target="_blank">@Nyall Dawson</a> and <a class="gmail_plusreply" id="m_5988072846211154521m_6067105776945187557gmail-plusReplyChip-3" href="mailto:matthias@opengis.ch" target="_blank">@Matthias Kuhn</a> <div><br></div><div>in the meantime I had to resolve compilation problems and OS update I'll show you what I'm doing to resurrect rastercalculator in modeler trying to evaluate if I'm doing well.</div><div><br></div><div>the principal problem (but not the only one) to run raster calculator in a modeler is to map input value to the formula. This is a generic problem that can be applied to any algorithm that need to map input in something internal to the algorithm.</div><div><br></div><div>The main problems is that the algorithm context scope hadn't information to allow this mapping. I added:</div><div><br></div><div>context.setExpressionContext(expContext);<br></div><div>here</div><div><a href="https://github.com/qgis/QGIS/blob/master/src/core/processing/models/qgsprocessingmodelalgorithm.cpp#L276" target="_blank">https://github.com/qgis/QGIS/blob/master/src/core/processing/models/qgsprocessingmodelalgorithm.cpp#L276</a><br></div><div>and naming the createExpressionContextScopeForChildAlgorithm scope "algorithm_inputs" (actually the added scope does not have name, because was not necessary)</div><div><br></div><div>and add this mapping in ::variablesForChildAlgorithm</div><div><a href="https://github.com/qgis/QGIS/blob/master/src/core/processing/models/qgsprocessingmodelalgorithm.cpp#L431" target="_blank">https://github.com/qgis/QGIS/blob/master/src/core/processing/models/qgsprocessingmodelalgorithm.cpp#L431</a><br></div><div>with value:</div><div><var name>: <maplayer instance></div><div>In this moment only <var name>_[extent] variable are added in this context scope</div><div><br></div><div>the idea, in the processAlgorithm python part, is to get the expression context from ProcessingContext and substitude <var name> with <maplayer source> in the formula that will be executed by QgsRasterCalculator</div><div><br></div><div>conceptually it works, but many other problems in context and parameter settings are present that seems they are more generic modeler problems I'm still trying to solve and reproduce them)</div><div><br></div><div>What I'm not sure is to use the expressionContext to store this information instead of a different or new contextScope. the advantages is that the new input parameters are available in the expression editor because available in the context.</div><div><br></div><div>as soon as I can I'll give you a PR where to talk about real code... in this moment I doing tests if my approach is (almost) correct and finding all limitation using these pathces in simple test models </div><div><br></div><div>Luigi Pirelli<br></div><div><div><div dir="ltr" class="m_5988072846211154521m_6067105776945187557gmail_signature"><br>**************************************************************************************************<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS 2nd Edition:<br>* <a href="https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition" target="_blank">https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition</a><br>* Hire me: <a href="http://goo.gl/BYRQKg" target="_blank">http://goo.gl/BYRQKg</a><br>**************************************************************************************************</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 4 Jul 2018 at 00:24, Luigi Pirelli <<a href="mailto:luipir@gmail.com" target="_blank">luipir@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I was supposing is was subject to the GSOC about qgis/grass... but I can be wrong.<br clear="all"><div><div dir="ltr" class="m_5988072846211154521m_6067105776945187557m_312373063506138273gmail_signature" data-smartmail="gmail_signature">Luigi Pirelli<br><br>**************************************************************************************************<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS 2nd Edition:<br>* <a href="https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition" target="_blank">https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition</a><br>* Hire me: <a href="http://goo.gl/BYRQKg" target="_blank">http://goo.gl/BYRQKg</a><br>**************************************************************************************************</div></div><br></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 3 Jul 2018 at 18:31, Giovanni Manghi <<a href="mailto:giovanni.manghi@gmail.com" target="_blank">giovanni.manghi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Luigi,<br>
<br>
> I know that some power users are stuk to 2.18 for the lack r.calc in grass7<br>
> integration in qgis (that seems will be solved soon)<br>
<br>
what is greatly missing (in GRASS7) is <a href="http://r.mapcalculator.py" rel="noreferrer" target="_blank">r.mapcalculator.py</a>, a script<br>
made on top of r.mapcalc that among the other things allowed us to<br>
have in Processing a nice way to use r.mapcalc (because it worked via<br>
normal description files while r.mpalcalc does not, and any attempt to<br>
make it work in Processing was not very succesful).<br>
<br>
Are you saying that this script is being ported in GRASS7?<br>
<br>
cheers<br>
<br>
-- G --<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div>
</blockquote></div>
</blockquote></div>