I am able to extract() from rasterstack and wrote a x,y txt file as discussed here How to extract values from rasterstack with xy coordinates?
However, when my I used a big rasterstack, I end up with memory issue.
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")
I would really appreciate any help.
Thanks in advance.