[gdal-dev] Problem reading a '.bil' file

Frank Warmerdam warmerda at h...
Mon Oct 30 10:07:18 EST 2000


Aleksey Naumov wrote:
> 
> Hi all,
> 
> I am having a hard time trying to read a '.bil' file. The file came with a
> corresponding
> '.hdr' file, so I assume that it's an ESRI .hdr Labelled file (EHdr driver).
> 
> Here's the content of the .hdr file:
> byteorder M
> layout bil
> nbands 1
> nbits 32
> ncols 304
> nrows 364
> ulxmap -115.717083
> ulymap 43.449583
> xdim 0.033333
> ydim 0.033333
> 
> I tried to read it with a simple C++ code borrowed from API tutorial (the exect
> code
> used is included below). Here's the output I get upon running:
> 
> Driver: EHdr/ESRI .hdr Labelled
> Block=304x1 Type=UInt32, ColorInterp=Undefined
> Min=0.000000, Max=4294967295.000000
> Computing min/max...
> Min=0.000000, Max=0.000000
> 
> Here the last line is supposed to show the actual values, since I force
> GDALComputeRasterMinMax() to recompute and take all numbers into account.
> 
> I can't understand why I get all zeroes (I get the same in OpenEv - obviously,
> it's based on GDAL)! I used Python to read the .bil file pixel by pixel and I know
> 
> that there are real numbers there...
> 
> I then thought that it't the byte order that's screwing things up (indeed, the
> numbers as read in Python were unrealistically huge). So I converted
> the original 'cbw00003.bil' to another one, reversing the bytes with
> pack() and unpack() from the struct module. Now the numbers are
> within the range 0 - 3611 (and 2147483648, must indicate no data or
> something...).
> 
> So I have this new '.bil' file and the corresponding '.hdr' file (I tried it both
> with "byteorder M" line and without it) and I still get only zeroes!
> 
> What am I doing wrong? Any clue would be appreciated...

Aleksey,

I am not quite sure why this isn't working. The gdal/frmts/raw/ehdrdatsaet.cpp
code does include code to look at the byteorder flag, and swap data if 
required. Could you send me your dataset? What platform are you working on?
Could you send you gdal/port/cpl_config.h file?

Best regards,

---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerda at h...
light and sound - activate the windows | http://members.home.com/warmerda
and watch the world go round - Rush | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list