1

I have several raster layers with costs associated to distances from certain cells. Some distances are positive (i.e. the further from the cell, the better) and others are the opposite (i.e. the closer, the better).

How can I use GRASS's commands to convert some layers to find the negative distance-costs? Could r.mapcalc work?

2

The GRASS command r.rescale (or r.recode for double/float values) can be used to do this.

Using the GRASS 7.2.0 manual's example, to convert data of the range 10 to 1500 into 0.1 to 15.0, you can use the following rule:

10:1500:0.1:15.0

Or for the original question, to 'invert' 10 to 1500 into 1500 to 10:

10:1500:1500:10

One further note to make when using r.recode is to enable the flag '-d' to force enable raster cells to hold a double value (i.e. to become a DCELL)

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.