4

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?

Taras
  • 32,823
  • 4
  • 66
  • 137
brink
  • 820
  • 9
  • 23
  • Yes, raster calculator https://docs.qgis.org/2.2/en/docs/user_manual/working_with_raster/raster_calculator.html the actual calculation depends on what you mean by invert. – Michael Stimson Nov 22 '17 at 01: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 '17 at 01: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. – Michael Stimson Nov 22 '17 at 01: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. – Michael Stimson Nov 22 '17 at 21:13

2 Answers2

5

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?

brink
  • 820
  • 9
  • 23
4

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"

Cheers

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
Gabriel Asato
  • 485
  • 3
  • 12