I am using the Raster calculator in a model builder workflow (QGIS 3.16), but get a very unspecific error when using algorithm outputs as input for the raster calculator:

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

Using the raster calculator with model inputs works fine. However whenever I use one of the (listed) algorithm outputs (e.g. the result of a rasterization operation or the previous result of a raster calculation), the model fails to execute, without giving further reason (it says to check the log messages, but they are exactly the same as above mentioned error).

Below are images of model and error.


raster calculator

I've tried/checked:

  • a reference raster needs to be given (I tried model inputs as well as algorithm outputs)
  • I tested real calculations as well the most simple one (identity, just adding the plain layer)
  • I tried renaming the algorithms (I thought maybe the names are to long or special characters are a problem)

None of that worked.

Is this a known issue?

Are there known workarounds?

The final formula I want to use would be the following. Is this feasible with other operators (not the raster calculator)?

  ("algorithm_output3"  +
    (100 * (
               ("algorithm_output1@1" < 25) AND ("algorithm_output2@1">= 30)
) * ("algorithm_output2@1">= 30)

2 Answers 2


I managed to work around the QGIS raster calculator by using gdal_calc. It is not as intuitive to work with, but once you get the hang of the syntax, it works just as fine (or even better, since it does not suffer from the bug of not being able to process previous algorithm outputs).

The doc provides some examples for the calculation syntax (using numpy.functions). The actual formula for my case I ended up using was:

minimum((C + (100 * logical_and(B < 25, A >= 30))) * (A >= 30), 100)


I encountered the same bug. If you make sure the Algorithm Output Raster is in your "Reference Layers" on the Raster Calculator then it seems to work for me. See screen shot below.

Issue is logged on GIT HUB here https://github.com/qgis/QGIS/issues/37831

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.