I'm new to R and using terra and cannot figure out this permission error. This exact code works on another researcher's computer, so I'm not sure why it's not working on my Rstudios. The folder and directory is correct, but I keep getting the same error. The wc2.1_30s folder contains some .tif files.

I want to name a folder with my variables baseline using this code: baseline <- list.files(pattern = "wc2.1_30s") and then examine the data with combined <- terra::rast(baseline)

then I get an warning "Warning: D:/Codingwork/wc2.1_30s: Permission denied (GDAL error 4)" and then "Error: [rast] cannot open file: D:/Codingwork/wc2.1_30s"

I'm running on Windows 10, 64bits on the most recent update of Rstudios.


1 Answer 1


If wc2.1_30s is a folder containing your TIF files, you do not want to do:

list.files(pattern = "wc2.1_30s")

you want:

list.files(path = "wc2.1_30s")

Also you should also add a pattern argument to select only the TIF files you are interested in. Something like:

list.files(path = "wc2.1_30s", pattern="^data[0-9][0-9]\\.tif$")

to match all .tif files named starting with "data" and two digits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.