I am very new in programming and I want to ask how can I make a scatterplot of two rasters in R and also get their correlation?
1 Answer
If the rasters have the same basis (extent, resolution etc) then you just get the values and plot them. Something like:
plot(values(r1), values(r2))
I'm not sure exactly what the "correlation of determination" is, but the simple "correlation" can be computed by:
cor(values(r1), values(r2))
Note these are both dependent on the rasters having identical grid structures.
-
1
-
1I'm never sure when raw rasters work and when you need
values()
so I played it cautious without testing! Oct 17, 2014 at 8:51 -
1Just for completeness. The coefficient of determination (R²) is the square of coefficient of correlation (r). Feb 7, 2019 at 22:51