1

I have 5 Raster files each depicting a soil property, all of the same area. I want to find the location with the "worst" combined soil properties. It's also important to note that the values of the layers don't have the same values. I tried r.series but I'm not sure if it is the right way to do it. From my understanding r.series compares all rasters at once and picks the min (if selected) for each location?

I also heard that I can use the raster calculator to get what I want, but I have no idea how to form an equation that does what I want.

Another thing I thought about was to convert the layers to vector data and try working with them, but since the layers are really large I don't want to wait 5 hours only to find it wouldn't work.

I know this may not be a straight forward question, but I've tried a lot of things and nothing works and at this point I'm kind of lost.

5
  • you can normalize each raster from 0 to 1 and then use r.series to calculate the sum. for each pixel.
    – HDunn
    Commented Nov 23, 2017 at 14:24
  • just so make sure i understand you: you suggest converting the absolute value of each pixel into a relative value, to make them comparable and thus making it possible to use r.series to get a pixel value that essentially says: "this pixel has a value of 1/2x" by summing up x of each layer? english is not my first language and the normalization i know is to get rid of redudant values in a database. Also im interested in how this works so ill be very thankful for a more in depth response. but im already thankful for your answer and will read up on what you suggested.
    – uybfi
    Commented Nov 23, 2017 at 14:36
  • yes, either by sum or by multiplication (then have a range from 0.01). you can use r.rescale for that purpose. grass.osgeo.org/grass64/manuals/r.rescale.html
    – HDunn
    Commented Nov 23, 2017 at 15:00
  • thank you! one last question: how can i "upvote" your answer or mark as the best answer? the help shows i can mark an answer, but i dont see any options here.
    – uybfi
    Commented Nov 23, 2017 at 15:09
  • I've edited my comments to an answer
    – HDunn
    Commented Nov 23, 2017 at 15:22

2 Answers 2

2

You can normalize each raster from its original values to a range between 0 to 1 and then use r.series to calculate the sum for each pixel and get the "worst" combined soil properties.

alternatively, you can multiply your rasters, again, with r.series, just make sure the ranges exclude the value 0.

To normalize each raster, you can use r.rescale.

1

Here is how you could do that in R

library(raster)
# example data
r <- raster(ncol=10, nrow=10)
r1 <- setValues(r, runif(ncell(r)))
r2 <- setValues(r, runif(ncell(r)) * 2)
r3 <- setValues(r, runif(ncell(r)) / 2)
r4 <- setValues(r, runif(ncell(r)) * 10)

s <- stack(r1, r2, r3, r4)

# linear transformation
x <- s / maxValue(s)

# mean pixel value
a <- mean(x)
plot(a)
# min pixel value
b <- min(x)


# another transformation:
y <- scale(s)

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.