我想从指示的文件夹中导入所有多个镶嵌栅格(每个镶嵌由7层组成)到我的R中。然后将它们作为单个多层栅格进行访问。
所以我做了:
# read all mosaics named "mos....img" in R
raster_data<-list.files(path=getwd(), pattern="mos.*.img$")
# read files as rasters
s <- stack(raster_data)
# check my imported rasters p.ex. raster n°8 from "s" raster stack
s[[8]]
而我的栅格s [[8]]仅包含1层,因此未导入整个镶嵌!
nlayers(s[[8]])
[[1]]
如果我分别阅读每个镶嵌图,它将起作用:
# read 1 mosaic (composed by 7 bands)
mosaic1<-brick("mosaic1.img")
# extract one band
band4<-subset(mosaic1, 4)
为什么“堆栈”工具不导入整个镶嵌图,而仅导入镶嵌图的一个带,并且如何排列呢?