0

i'm trying to use de raster package to read a multilayer (multiband) image (ENVI format [.hdr]) that have 160 values of refletance and 160 values of wavelength per pixel, but when i use the code that i developed, the program returns only 1 band and the refletance value associated.section1=raster("./x") getValuesBlock(section1, row=1, nrows=1, col=1, ncol=1 )

2 Answers2

0

Well, from the looks of it , it seems to me that you want to read a particular band of a raster file into the R environment ,

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

Change the values of theband parameter of the raster() method to control the band id of your raster. Hope this helps

Thedarknight
  • 181
  • 1
  • 3
0

To create a multi-layer Raster object, you should use the brick function if they layers are in one file, or the stack function if they are in multiple files.

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

# a single cell value
b[1]
Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63