我想使用
之类的东西library(raster)
library(sp)
## Create raster
r <- raster(ncol=40, nrow=20)
class(r)
## display coordinates
coordinates(r)
## create new coordinates
x <- matrix(rexp(200, rate=.1), ncol=40, nrow=20)
y <- matrix(rexp(200, rate=.1), ncol=40, nrow=20)
## Set new coordinates
coordinates(r)[,1] <- as.vector(x)
coordinates(r)[,2] <- as.vector(y)
但这会产生错误:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘coordinates<-’ for signature ‘"RasterLayer"’
是否有一种简单的方法可以替换栅格中的经纬度?