如何从栅格堆栈R中提取栅格图层名称?

时间:2014-09-08 15:36:05

标签: r raster

我有一个我用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'

1 个答案:

答案 0 :(得分:10)

使用names功能描述栅格堆栈名称。例如:

> names(sf)
[1] "subset.1" "subset.2" "subset.3"

> names(sf)[1]
[1] "subset.1"