1

What is the correct syntax for the 'Predefined expressions' feature of the Raster Calculator of QGIS 3.14? How one can replace layer names with variables in the expression being saved (so they can be selected from dropdowns later, just like in predefined NDVI formula)? Is adding some other variables possible?

I mean the calculator which can be found in Processing Toolbox > Raster analisys > Raster calculator, not the one from the 'Raster' menu > Raster Calculator. (By the way, why there are two raster calculators?)

1

I've found out that one can simple put a json file called rastercalcexpressions.json to the PROFILENAME\processing folder, where 'PROFILENAME' is the QGIS profile folder (Settings > User profiles > Open active profile folder).

This file should contain expressions to use in raster calculator with bands replaced with [bandname] placeholders, something like this:

{"NDVI": "([NIR] - [Red]) / ([NIR] + [Red])", "NDSI": "([Green] - [SWIR1]) / ([Green] + [SWIR1])"}

Then the bands can be selected with dropdown menus later.

That's not the full answer, I still don't know how to save an expression (and name its input fields) directly from the calculator, but that one works too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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