【发布时间】:2021-10-18 18:50:45
【问题描述】:
我正在尝试搜索文件夹并根据字符值导入多层栅格。
如何导入与字符串匹配的文件并保留其名称?
#use shp and y to find orthos
ortho <- crop(MrSID_shp, y)
s <- ortho[[2]]
s
#"3_5" "2_5"
#use s values to search folder with corresponding name
file.is <- Sys.glob("*.tif")
print(file.is) # "0_0.tif" "2_5.tif" "3_5.tif"
for (i in seq_along(file.is)){
file.is[[i]] <- stack(file = file.is[i],
pattern = s,)
}
#this results in empty values
我尝试了 grep、find 和 lapply,但都没有成功。我已经能够使用“s”模式导入“3_5.tif”,但我需要导入所有匹配的文件,而不仅仅是一个。
谢谢
【问题讨论】: