我有一个大型的栅格数据集,我正在尝试使用Maxent来预测栖息地的适宜性。我在速度方面遇到了问题,因此我将代码重写为基于此post的并行处理。
ncores = 4
cl = parallel::makeCluster(ncores)
doParallel::registerDoParallel(cl,ncores)
rows=1:nrow(env)
split=sort(rows%%ncores)+1
outname="envOut"
prediction = foreach(i=unique(split), .combine=c) %dopar% {
rows_sub=rows[split==i]
sub = raster::crop(env,raster::extent(env,min(rows_sub),max(rows_sub),1,ncol(env)))
raster::predict(object=env, model = model1,
filename=paste("I:/GIS/Projects/LISU/",outname,i,".tif",sep=""))
gc()
}
stopCluster(cl)
然而,当我这样做时,使用了超过500 GB的硬盘空间,并且我无法生成输出栅格。基于这些posts,我在我的代码块之前添加了以下代码行。
rasterOptions(tmpdir="I:/GIS/tmpdir")
I驱动器是一个拥有大量空间的外部硬盘驱动器位置。然而,这个命令似乎被忽略了,因为当我重新运行并行预测时,我的硬盘又满了。有什么建议吗?
发布于 2016-08-17 20:34:01
在Windows中,我设置了我的环境变量TMPDIR=I:\GIS\tmpdir.
当我启动R时,输入tempdir()
检索到我想要使用的临时目录的正确路径。
我仍然不确定rasterOptions(tmpdir=...)
到底是做什么的。
https://stackoverflow.com/questions/39007325
复制相似问题