我使用的是doSNOW包,更具體地說是parLapply函數對大柵格數據集(操作系統:Windows x64)列表執行重分類(以及後續的其他操作)。R中的大柵格並行處理(windows)
代碼看起來有點像這樣簡約的例子:
library(raster)
library(doSNOW)
#create list containing test rasters
x <- raster(ncol=10980,nrow=10900)
x <- setValues(x,1:ncell(x))
list.x <- replicate(9 , x)
#setting up cluster
NumberOfCluster <- 8
cl <- makeCluster(NumberOfCluster)
registerDoSNOW(cl)
junk <- clusterEvalQ(cl,library(raster))
#perform calculations on each raster
list.x <- parLapply(cl,list.x,function(x) calc(x,function(x) { x * 10 }))
#stop cluster
stopCluster(cl)
的代碼實際上按預期工作。當我想繼續處理結果時會出現問題。我收到此錯誤信息:
> plot(list.x[[1]])
Error in file(fn, "rb") : cannot open the connection
In addition: Warning message:
In file(fn, "rb") :
cannot open file 'C:\Users\*****\AppData\Local\Temp\RtmpyKYdpY\raster\r_tmp_2016-02-29_133158_752_67867.gri': No such file or directory
據我瞭解,因爲柵格是相當大的,它們被保存在磁盤上的臨時文件。當我關閉雪羣時,這些文件無法再被訪問。
所以我的問題是,一旦集羣關閉,我如何訪問數據?我可以繼續使用這種方法嗎?
謝謝!
謝謝山姆!如果你想到它,這實際上是相當明顯的......嘗試並像魅力一樣工作。 – Val