Hi 

I am doing a lot of raster calculations repeatedly (in a loop of sorts). As might be expected, this process is generating a lot of temporary files and filing up my hard drive before my script finishes. The first step in my script is to stack a set of very large rasters. This stack is then the input for the function that I'm using (e.g. the loop). Can I add in a line in my loop (e.g. removeTmpFiles) to delete temporary files created during the loop without ruining the integrity of the raster stack?  

For example:

files<-list.files(pattern=".tif")
myStack<-stack(files)

myFunction<-function(x, rasterStack, y, z){
# several calculations using the raster stack and x, y, z
# non-raster results from the calculations get saved to file using write.csv()
removeTmpFiles(h=0) # remove temp. raster files from disk???
}

lapply(x=list_of_x_values, myFunction, rasterStack=myStack, y=something, z=somethingelse)

Is the removeTmpFiles line appropriate here?

Thanks for the help!
	[[alternative HTML version deleted]]

