Skip to content

get rgdal to read ENVI raster?

2 messages · Felix Andrews, Roger Bivand

#
Thanks Michael

The extension is "flt" (float type). This resulted in a sensible image:

foo <- readBin("G:/Projects/Tuross/surface_files/rainfall_surface/year2000/rainGrid_20001.flt",
"double", n=200*200, size=4, endian="little")
foo[foo==-9999] <- NA
range(foo, finite=T)
# 18.83187 80.23850
image(matrix(foo, ncol=200))
# sensible image, but flipped vertically I think

This is what GDAL does:

grid1 <- readGDAL("G:/Projects/Tuross/surface_files/rainfall_surface/year2000/rainGrid_20001.flt")
# G:/Projects/Tuross/surface_files/rainfall_surface/year2000/rainGrid_20001.flt
has GDAL driver EHdr
# and has 200 rows and 200 columns
# Closing GDAL dataset handle 0x02248358...  destroyed ... done.
str(grid1 at data[[1]])
# int [1:40000] 118 215 97 66 180 213 96 66 23 133 ...

So the problem is that it thinks it is an integer type, whereas in
fact it is a 4-byte float type.

As a temporary hack, maybe I can use GDAL to import it, then just
replace the @data slot with the correct numeric data.

Felix
On 8/8/07, Michael Sumner <mdsumner at utas.edu.au> wrote:
--
Felix Andrews / ???
PhD candidate
Integrated Catchment Assessment and Management Centre
The Fenner School of Environment and Society
The Australian National University (Building 48A), ACT 0200
Beijing Bag, Locked Bag 40, Kingston ACT 2604
http://www.neurofractal.org/felix/
voice:+86_1051404394 (in China)
mobile:+86_13522529265 (in China)
mobile:+61_410400963 (in Australia)
xmpp:foolish.android at gmail.com
3358 543D AAC6 22C2 D336  80D9 360B 72DD 3E4C F5D8
#
On Wed, 8 Aug 2007, Felix Andrews wrote:

            
I think you'll find that the data are integer - the rgdal code simply 
calls GDAL anyway (in your case on Windows freshly built GDAL 1.4.2). What 
does gdalinfo say about the file - I guess you have GDAL utilities 
installed on your system somewhere?

Roger