[GIS] Scatterplot between two rasters in R

correlationrrasterscatterplotstatistics

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?

Best 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.