如何使用光栅包识别图像的所有波段(图层)?

问题描述 投票:0回答:2

我正在尝试使用de raster包来读取多层(多频带)图像(ENVI格式[.hdr]),它具有160个refletance值和160个每像素波长值,但是当我使用我开发的代码时,程序只返回1个波段,refletance值与.section1=raster("./x") getValuesBlock(section1, row=1, nrows=1, col=1, ncol=1 )相关

r package layer raster rgdal
2个回答
0
投票

好吧,从它的外观来看,在我看来,你想要将一个特定的光栅文件带读入R环境,

require("raster")
dir.file<-"dir/file.hdf"
#Reading the first band of the raster image
band1<-raster(dir.file,band=1)

更改band方法的raster()参数的值以控制栅格的band id。希望这可以帮助


0
投票

要创建多层Raster对象,如果它们在一个文件中,则应使用brick函数;如果它们在多个文件中,则应使用stack函数。

library(raster)
# example file name
f <- system.file("external/rlogo.grd", package="raster")
b <- brick(f)
b

# a single cell value
b[1]
© www.soinside.com 2019 - 2024. All rights reserved.