I am an R novice, especially when it comes to spatial data. I am trying to find a way to efficiently import multiple (~600) single-band raster (.tif) files into R, all stored in the same folder. Not sure if this matters but note that, when viewed in a folder on my Mac and Windows Parallel VM, there are the following five (5) file formats for each .tif = .TIF; .tfw; .TIF.aux.xml; .TIF.ovr; .TIF.xml. At any rate, the following code (and other similar variants I've tried) does not seem to work:
library(sp)
library(rgdal)
library(raster)
#path to where all .tif files are located
setwd("/path/to/workingdirectory")
#my attempt to create a list of my .tif files for lapply
temp = list.files(pattern="*.tif")
temp #returns 'character(0)'
#trying to use the raster function to read all .tif files
myfiles = lapply(temp, raster)
myfiles #returns 'list()'
Is there a way to use some form of loop to import all raster files efficiently?
pattern="*.TIF"
. – Servant