我有一个我用geotiff创建的光栅堆栈:
ras = "C:/temp/subset.tif"
b1 = raster(ras, band = 1)
b2 = raster(ras, band = 2)
b3 = raster(ras, band = 3)
sf = stack(b1, b2, b3)
打印堆栈会产生以下信息:
> print(sf)
class : RasterStack
dimensions : 701, 1151, 806851, 3 (nrow, ncol, ncell, nlayers)
resolution : 1, 1 (x, y)
extent : 301259.5, 302410.5, 4694849, 4695550 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=13 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0
names : subset.1, subset.2, subset.3
min values : 51, 64, 65
max values : 229, 224, 218
如何从堆栈中提取单个图层名称?例如:
'subset.1'
答案 0 :(得分:10)
使用names
功能描述栅格堆栈名称。例如:
> names(sf)
[1] "subset.1" "subset.2" "subset.3"
> names(sf)[1]
[1] "subset.1"