Using Calculator in QGIS Graphical Modeler

I think this is an issue with the code in the file (for me the path is: /QGIS 2.18/apps/qgis/python/plugins/processing/modeler/CalculatorModelerAlgorithm.py). It seems when running the algorithm, the code iterates through all available variables (which is 10) and assigns them their corresponding value.

But this only seems to work if all variables are stated in your formula, otherwise only the variables included in your formula would be given a parameter (NUMBERX). I.e. from your log:

Parameters: 
    FORMULA =(g-f)/a, 
     NUMBER0 =2,   --> a
     NUMBER1 =3125884.941,   --> f
     NUMBER2 =3135324.941,   --> g

A quick remedy is to write your formula and include all the variables which are not used by multiplying them by 0.


  • So for your first calculator, try replacing:

    (e - d) / b
    

    with:

    (e - d) / b + (a+c+f+g)*0
    
  • And for your second calculator, try replacing:

    (g - f) / a
    

    with:

    (g - f) / a + (b+c+d+e)*0