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 )
Asked
Active
Viewed 831 times
0

GustavoRiga
- 1
- 1
-
You should provide the code used to read the files and, better, provide also access to the data. – Paulo E. Cardoso Nov 14 '14 at 00:39
-
Use `brick` instead of `raster`. And please read `?brick`. – Nov 14 '14 at 01:29
-
Thank's a lot Pascal. Your tip solved my problem. Thank's Paulo Cardoso. – GustavoRiga Nov 14 '14 at 12:10
-
Guys, i studied all results that i received and concluded that i found the wavelength and i didn't find the reflectance values. How can i get the reflectance values associated to the wavelength? – GustavoRiga Nov 20 '14 at 13:42
2 Answers
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