I am looking for the right formula for reclassifying a slope raster. I need to switch the values 1 = bad, 10 = good to 1 = good, 10 = bad. This Formula worked fine using the normal raster calculator: 10 - %"Recoded@1"% + 1 but I can't figure out the right formula using the SAGA or Gdal Raster Calculator for my processing model. Any ideas!?

  • 1
    Do you need to switch just the values 1 and 10, or is it a continuous raster with value ranges between 1 and 10?
    – HDunn
    Apr 24 '17 at 18:28

A direct answer using SAGA Raster Calculator, would be 11- g1 (same as 10 - g1 + 1).

Alternatively, SAGA | Raster tools Invert grid does the same job.

If we test with this example (sorry... I forgot to input 1... and ended up with 10 - g1 + 2).

enter image description here

Since OP's equation had been successful with QGIS raster calculator, I will not worry too much about continuous data. If input was continuous data (e.g. 1.23 - 10.00), the output gets funny and easily recognized.

enter image description here


Try using the SAGA Tool "Reclassify values". Here you can easily replace one value with another one (for example 1 with 10). Depending on your data, you might have to repeat the process several times to achieve the desired format

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.