I want to get a pairwise distance matrix between the centroids of every cell with every other cell in a raster layer. As well, I'm trying to figure out how to get the pairwise matrix of differences between values within the raster layer.
I tried looking at the {gdistance} and {spatstat} packages but it doesn't seem like there is a function for this.
Here is an example:
df <- data.frame(x = rnorm(100, 5, 3), y = rnorm(100, 10, 6))
rast <- raster()
ncol <- 20
nrow <- 20
test <- rasterize(df, rast, FUN=mean)
plot(test, xlim=c(min(df$x), max(df$x)), ylim=c(min(df$y), max(df$x)))
Any ideas?