I ran a proximity (raster distance) function and I would like to invert the result.

Is there a simple way to do this without converting it back to vector format and editing the attribute table?

  • Yes, raster calculator docs.qgis.org/2.2/en/docs/user_manual/working_with_raster/… the actual calculation depends on what you mean by invert. Nov 22, 2017 at 1:05
  • The proximity raster function creates pixels with higher values the further away from the object they are. I would like to invert those values so the numbers get smaller as they get further.
    – brink
    Nov 22, 2017 at 1:11
  • 4
    Use an n-R calculation where n is a constant and R is you cell value.. where R is small the output is large, where R is large the output is small. Nov 22, 2017 at 1:15
  • No worries! I'm glad you got a result. Can you please answer your own question, with screenshots preferably, for the benefit of users in the future who have the same requirement. Nov 22, 2017 at 21:13

2 Answers 2


Thanks to Mr. Stimson I used the expression 1000-(raster layer) to get the inverted raster result. I chose 1000 because it didn't have to be an exact invert and I didn't want negative numbers. I need to run it through r.cost algorithm which creates an error if there is a negative number. enter image description here

If you are wondering what number to use try this link How to extract pixel value counts from a raster in QGIS?


Invert values with QGIS Raster Calculator:

-1 * "yourRaster@1" +  MAX("yourRaster@1")

but MAX() is not working properly according to some QGIS Bugs Reports.

Instead of MAX() put the maximum value of your raster. Then:

-1 * "yourRaster@1" + "put the maximum value of your raster"


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.