我是一个R语言初学者,特别是在空间数据方面。我正在尝试找到一种将多个(约600个)单波段栅格(.tif)文件高效导入到R中的方法,所有文件存储在同一个文件夹中。不确定是否有影响,但请注意,在我的Mac和Windows Parallel VM上查看文件夹时,每个.tif文件有以下五(5)种文件格式=.TIF; .tfw; .TIF.aux.xml; .TIF.ovr; .TIF.xml。无论如何,以下代码(以及我尝试过的其他类似变体)似乎都无法正常工作:
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()'
有没有一种有效的方法可以使用某种形式的循环来高效地导入所有光栅文件?
pattern="*.TIF"
。 - Parfait