我有Tiff格式的14個光柵文件,我想讀取一系列像素(相同文件位置)的值。但是,當我運行R代碼時,預期結果並未顯示出來。你能告訴我爲什麼嗎?預期結果不打印for for循環
#set working directory#
path <- 'E:/TSL_VCF/Tiffs'
setwd(path)
#list tiff files in the working directory#
list.files(path, pattern = 'tif')
#count the number of tiff files#
mylist <- list.files(path, pattern = 'tif')
mylength <- length(mylist)
#get values for certain "location"#
for (i in 1:mylength){
myraster <- raster(mylist[i])
mymatrix <- as.matrix(myraster)
mymatrix[1,771]
}