I'm trying to analyze a subset of the Woldclim bioclimatic data (19 raster layers) that covers the Canadian Arctic. I'd like to see how correlated the layers are. When using the layerCor function from the terra package, I keep getting the following error message:

cor_present_temp <- layerCor(bioclim_present, "pearson", na.rm = TRUE)

Error in h(simpleError(msg, call)) :
Error in evaluating the argument ‘x’ in selecting a method for function ‘global’: [is.na] insufficient disk space (perhaps from temporary files?)

After trying to run this code, my entire hard drive become full. I have to shut R down to erase the temporary files

So, I tried splitting the dataset into 4 groups of 5-6 layers. However, when I try to run this analysis, I still get the error message when running the second dataset. Shouldn't the temporary files be gone once the analyses is complete? Can I erase them within R so that I don't have to open and close R to run the full analysis?

  • The "perhaps from temporary files" thing is only a "perhaps". How big is your raster?
    – Spacedman
    Feb 25 at 16:27
  • The whole set of 19 layers is 12GB. I'm reasonably certain that the temporary files are in fact the issue. I was having issues with them not deleting up close earlier in the week and I was having to delete them manually Feb 25 at 17:01
  • Do you know where they are? R's default dir for temp files is given by tempdir() but there's no guarantee any function is going to use that and not stash temp files somewhere else.
    – Spacedman
    Feb 25 at 18:49
  • As far as I can tell they are going to the directory specified by tempdir(). As I mentioned, I did have to delete the files manually several times Feb 25 at 19:18
  • 1
    tmpFiles(current = TRUE, remove = TRUE), I think.
    – dbaston
    Feb 26 at 20:24


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.