qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.59k stars 3.01k forks source link

Processing Raster Calculator not working in Processing Graphical Modeler #37831

Open ghtmtt opened 4 years ago

ghtmtt commented 4 years ago

Describe the bug Native Processing Raster Calculator is not working in Processing Modeler. I tried with both complicated and super simple models and simple formulas. With the exact same data and outside the Modeler, the Raster Calculator is working nice.

Here the model in attach test.model3.zip

How to Reproduce

In attach you can find a simple model that calculates the slope and the hillshade of a raster layer and these 2 outputs are then summed. I get the following error in the log

An error occurred while performing the calculation
Error encountered while running Raster calculator
Execution failed after 1.39 seconds

and the layer is still created but with values from 1.79769e+308 to -1.79769e+308 (actually empty).

If you try to create both slope and hillshade in the toolbox and then use the raster calculator outside the modeler than it works just perfectly.

QGIS and OS versions

QGIS 3.15 in Linux

I had a look and there are similar issues #32753, #33338

katxeus commented 4 years ago

I too face the same bug. Same error message on the simplest of models. Thought i was something wrong with my local installation but the same for other fresh QGIS installs.

M5610020 commented 4 years ago

I am having a similar issue of the native raster calculator not working while using input from the output from algorithm.

luipir commented 4 years ago

@ghtmtt did you check localization? e.g. run qgis in English

luipir commented 4 years ago

I did PR in https://github.com/qgis/QGIS/issues/32753 but was not accepted because it's necessary a deeper refactoring and this needs time. The closed PR was just a patch.

ghtmtt commented 4 years ago

@ghtmtt did you check localization? e.g. run qgis in English

yep. I tried in different languages (actually my default locale is en)

Pedro-Murteira commented 2 years ago

Still valid on QGIS 3.22.3.

AdrianChC commented 2 years ago

it also happens to me. If I use the native raster calc in the model builder with existing layers it works fine. But if the inputs are temporal layers from the model it just doesnt work.

fpirotti commented 2 years ago

Same here, when using inputs from temporal layers the raster calculator in the model builder will not work; likely the issue is related to language settings and characters in the parsed temporary output variable. E.g. my guess is that in the expression box the extra single quote in italian translation of "from", thus : "'Output' from algorithm 'XXX'@1" becomes "'Output' dall'algoritmo 'XXX'@1" and this extra single quote seems to be messing up the parsing of the expression. My two cents. Hope this gets fixed and I am willing to help where I can as raster calculator is a very common step in models. PS the work-around is to use GDAL's raster calculator.
immagine immagine

AdrianChC commented 2 years ago

Hi Francisco, I could fix it by changing the language of QGIS to EN, the native language of programming, I guess. I also made sure that the names of the 'Outputs' were in english to. Take a look screen. Now it works fine, just lost my shortcuts ;) I work with QGIS 3.16.11 (LTR)

fpirotti commented 2 years ago

Thank you Adrian, yes I know, in english it works fine, but I teach several courses to italian students and switching languages adds complexity that I would like to avoid. @ghtmtt @gioman I think changing in file https://raw.githubusercontent.com/qgis/QGIS/master/i18n/qgis_it.ts from tag `'{0}' dall'algoritmo '{1}' to

'{0}' da algoritmo '{1}' ` might fix the issue. I joined transifex QGIS Desktop team to do that and I am waiting for acceptance - hopefully it will work.
nmaysgs commented 2 years ago

Have this issue occuring in 3.16.7 and 3.20 with language EN_au. Cannot use the raster calculator in model builder due to temporary output issue, something to do with the naming of the output?

Kapanther commented 2 years ago

I have found the fix here is to make sure that the "Reference Layer(s)" contains your algorithm output(s). Otherwise it doesn't work. In the meantime i would suggest using the GDAL Raster Calc tool if your still having issues

Kapanther commented 2 years ago

image

mominulhasan commented 1 year ago

I was having the same problem. The solution is to select all the inputs used in the calculation as reference layers. If one of them is missing, it will return an error.

dawgermany commented 1 year ago

Im having this issue on english qgis 3.32

RobinFoxie commented 1 year ago

I'm also still having this problem on English QGIS 3.32. A calculation will work when done as an individual operation, but try to employ the same calculation in the GM using output from a prior calc as an input and it breaks the model every time even when the reference layer is set correctly.

As noted by others, the GDAL raster calculator works fine (even though I don't like using it as much).