Hi Puneet-

The format is similar but not the same as ENVI file format.  You could
probably use the _read_envihdr() routine as a start to implement a real
read routine but I think using the information on the file format from the
site you got the data from would be enough info to go on:

> Each layer consists of two files. One file with the actual data (.BIL);
> and one accompanying text (header) file (.HDR). Sometimes there are
> two more header files (.GRD and .RDC) for use in DIVA-GIS or IDRISI
> (see below). The data files (.BIL) are sequential binary files in which
> values are stored line by line from the upper-left to the lower-right corner.
> Each cell (pixel) is a signed 2 byte integer value. If you find that your
> application reports very large numbers, and no negative numbers, the
> files were probably interpreted as unsigned integers

I would expect a header for readflex like [ { Type=>'short', NDims=>3,
Dims=>[NCOLS,1,NROWS]}] might work.  You'll need to check that
the axis order is correct but if you know what the data should look
like you'll know which is correct.

Thanks for catching the bug.

Cheers,
Chris

On Tue, Nov 22, 2011 at 4:44 PM, Puneet Kishor <[email protected]> wrote:
>
> On Nov 22, 2011, at 3:08 PM, David Mertens wrote:
>
>> On Tue, Nov 22, 2011 at 1:06 PM, Puneet Kishor <[email protected]> wrote:
>>
>>> Greetings,
>>>
>>> Is it possible to read .bil files with PDL? readenvi at
>>> http://cpansearch.perl.org/src/CHM/PDL-2.4.9/IO/ENVI/readenvi.pdl seems
>>> promising, but I wasn't able to test with it because it had "too many
>>> errors" when trying to run it.
>>>
>>> I am hoping to dissect a few climate data grids that I downloaded from
>>> http://www.worldclim.org/
>>>
>>>
>>> --
>>> Puneet Kishor
>>> _______________________________________________
>>> Perldl mailing list
>>> [email protected]
>>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>>
>>
>> I'd never heard of this IO module and figured I should look into who added
>> it. You're in luck: this was committed by The Pumpking (i.e. Chris
>> Marshall), certainly not a one-time committer. :-)
>>
>> While I'm sure Chris will answer you soon, he would probably appreciate if
>> you pasted the errors that you get and, especially, the version of PDL that
>> you're using. It looks like he updated this last during the development
>> cycle that lead to PDL 2.4.8. Do you have 2.4.8 or 2.4.9, or an earlier
>> version?
>
> I am using PDL 2.4.6, because that is the latest version available at this 
> time via macports. I am trying to figure out how to upgrade that to 2.4.9, 
> but that is a different project. In any case, I don't think the PDL version 
> is the issue here. With regards to the error in readenvi.pl it was just a 
> typo, on line 145
>
>> if eof($hdrfile) {
>
> should read
>
>> if (eof($hdrfile)) {
>
>
>
> It seems to me that I can possibly use that file as a template to write a new 
> program for reading these Worldclim files which are very simple .bil files. 
> They do have a header file, but it is not the kind of header that FlexRaw (or 
> FastRaw) expects. Here is a typical header
>
>        BYTEORDER     I
>        LAYOUT        BIL
>        NROWS         18000
>        NCOLS         43200
>        NBANDS        1
>        NBITS         16
>        BANDROWBYTES  86400
>        TOTALROWBYTES 86400
>        BANDGAPBYTES  0
>        NODATA        -9999
>        ULXMAP        -179.995833333333333
>        ULYMAP        89.995833333333333
>        XDIM          0.008333333333333333
>        YDIM          0.008333333333333333
>
>        DatabaseName  WorldClim
>        Version       1.4
>        Release         3
>        Created       20051226
>        Projection    GEOGRAPHIC
>        Datum         WGS84
>        MinX          -180
>        MaxX          180
>        MinY          -60
>        MaxY          90
>        MinValue      -258
>        MaxValue      316
>        Variable      tmin
>        month         September
>        Units         deg C * 10
>
> I have to figure out what information to extract from the above to create a 
> FlexRaw compatible header the way readenvi.pl does, but am a loss for now. I 
> have tried something like the following, but with no luck
>
>        byte
>        3
>        43200 18000 1
>
>
>
>>
>> David
>>
>> --
>> Sent via my carrier pigeon.
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to