[GIS] Statistical comparison between different rasters using R

rrasterruslestatistics

I need to compare, statistically, different rasters with a pattern raster (in this case a Revised Universal Soil Loss Equation (RUSLE) raster). I used different methods to calculate the environment vulnerability, and now, I need to calculate which method is closer to the RUSLE raster. I thought about subtracting each method raster to the RUSLE raster and then compare the means of the resulting rasters.

Anyone have any idea using R?

Best Answer

I thought about subtracting each method raster to the RUSLE raster and then compare the means of the resulting rasters.

That is not a great approach as the mean can be zero, but the errors very large. Root Mean Square Error is perhaps the most common statistic used for comparisons like this.

To illustrate, I create two RasterLayer objects with random numbers, and one layer with the RUSLE data:

library(raster)
r <- raster(ncol=10, nrow=10)
set.seed(1)
r1 <- setValues(r, runif(ncell(r)))
r2 <- setValues(r, runif(ncell(r)))
rusle <- setValues(r, runif(ncell(r)))

We need a function to compute RMSE

RMSE <- function(x, y) { sqrt(mean((x - y)^2)) } 

Now use it:

RMSE(values(rusle), values(r1))
#[1] 0.3651395
RMSE(values(rusle), values(r2))
#[1] 0.3942261

The winner is r1 (but not by much)

Related Question