我能够从rasterstack中提取()并编写一个x,y txt文件,如下所述 How to extract values from rasterstack with xy coordinates?
但是,当我使用大型rasterstack时,我最终会遇到内存问题。
library(raster)
r <- raster(nrow=1000, ncol=1500)
s <- stack( sapply(1:366, function(i) setValues(r, rnorm(ncell(r), i, 3) )) )
s[1:3]<-NA
vals<-extract(s,1:ncell(s))
Warning messages:
1: In s[1:3] <- NA :
Reached total allocation of 1535Mb: see help(memory.size)
2: In s[1:3] <- NA :
Reached total allocation of 1535Mb: see help(memory.size)
coord<-xyFromCell(s,1:ncell(s))
combine<-cbind(coord,vals)
write.table(combine,"xyvalues.txt")
我真的很感激任何帮助 提前致谢。