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 )
How to do the raster package identify all bands (layers) of a image?
878 views Asked by GustavoRiga At
2
There are 2 answers
0
On
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
To create a multi-layer Raster object, you should use the
brick
function if they layers are in one file, or thestack
function if they are in multiple files.