[R-sig-Geo] Import BIL files in R, without the hdr file

Guillermo Olmedo folmedo at mendoza.inta.gov.ar
Tue Mar 27 15:47:20 CEST 2012


Hi list!

I'm trying to import a BIL binary file into R. I've obtained the file 
running a soft called TIMESAT[1] but i only have the BIL file, not the 
HDR. Because i know how timesat generates the files I've the number of 
cols ands rows. Also i know the file its a 16 bit signed integer and 
little endian. I've followed the procedure here [2] and the info i know 
from the file to write my own hdr. But still doesnt work. Without the 
hdr file i still can import the bil file into ERDAS using import binary 
and it works flawlessly, but i don't want to use ERDAS.

This is my hdr file:
BYTEORDER      I
LAYOUT         BIL
NROWS          79
NCOLS          107
NBANDS         1
NBITS          16
BANDROWBYTES   80
TOTALROWBYTES  80
PIXELTYPE      INTEGER
ULXMAP         0
ULYMAP         0
XDIM           107
YDIM           79

Maybe Bandrowbytes and totalrowbytes are wrong. At this moment the 
spatial location doesnt matters so i left ulxmap and ulymap as 0.

My code is:
BIL <- raster("amplitud.bil", native=T)
dataType(bio) <- 'INT2S'
plot(BIL)

And the same result with:
BIL <- raster(ncols=107, nrows= 79)
BIN <- readBin("amplitud.bil", what="integer", n=8453, endian="little", 
signed=TRUE, size=2)
BIL <- setValues(BIL, BIN)
plot(BIL)


With the img generated in ERDAS i can compare with the R result and 
clearly its not working good.

Also, here you can have a copy of my files: 
http://ubuntuone.com/116tXWeA7rrwOc9SWsp6Wl (63kb)

Anyone have a better recipe?

Thanks in advance, regards!


[1] http://www.nateko.lu.se/TIMESAT/timesat.asp
[2] http://r.789695.n4.nabble.com/importing-bil-files-td1677546.html

-- 
Ing. Agr. Guillermo Federico OLMEDO
Laboratorio de Geomática
Área de Recursos Naturales
EEA INTA Mendoza

Oficina: San Martín 3853. Mayor. Drummond.
Luján de Cuyo. Mendoza.
ARGENTINA (M5507EVY)
Tel: +54 (261) 496 3020 int. 252 / Cel. 261 6779074
http://www.inta.gov.ar/mendoza/invest/Gr_RecursosNaturales.htm



More information about the R-sig-Geo mailing list