[R-sig-Geo] Find the subset of a raster that best matches another raster

David Wang dw2116 at outlook.com
Mon Nov 20 18:37:29 CET 2017


Hello,


I have two raster objects of identical resolution but different sizes. And I need to find a subset of raster B that is most similar to raster A by for example a simple correlation measure. This subset of course needs to have the same size as A. Now I could loop through the dimensions of A and crop all possible subsets of size dim(A) and locate the one that has the highest correlation with A. However, I wonder if there are any more efficient algorithms to solve the problem.


library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))
A <- crop(b[[1]], extent(b[[1]], 20, 60, 25, 75))

B <- b[[2]]

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list