[R-sig-Geo] Unable to set temporary directory when using raster in R
Wall, Wade A ERDC-RDE-CERL-IL CIV
Wade.A.Wall at erdc.dren.mil
Wed Aug 17 20:02:40 CEST 2016
Hi all,
I am trying to use parallel processing with raster::predict, but am running into some issues because of the size of the raster files. I have tried to set the temporary directory, but it seems to be ignored. The drive I am trying to write to is an external hard drive and I am using Windows 7
Here is the code I have been using:
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), .packages = c("raster"), .combine=c) %dopar% {
raster.options(tmpdir="I:/GIS/tmpdir") ## my attempt to set the temporary directory
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)
When I run the script, R continues to write to C:/Users/Wade/AppData/Local/Temp/...
Any hints as to why this is happening?
Wade
More information about the R-sig-Geo
mailing list