[ncl-talk] reading PRISM .bil files?

Daniel Barandiaran dbarandiaran at gmail.com
Fri Oct 17 12:05:30 MDT 2014


Great, thanks for your help guys!

On Fri, Oct 17, 2014 at 11:42 AM, David Brown <dbrown at ucar.edu> wrote:

> Following up on Rick's comments, he is exactly right about the format.
> I downloaded a sample precipitation file from the web site, and tried
> to read and plot it using the suggestions at the web page Rick
> referred to. The function 'cbinread' works well and the data is little
> endian, so no byte swapping is needed on my Intel-processor-based
> machine. The data is written from top to bottom, so the Y Axis does
> need to be reversed to plot in NCL using the native projection which
> is basic lat/lon (cylindrical equidistant).
>
> Here is the code and attached is the PNG file output.
>
> dat =
> cbinread("PRISM_ppt_early_4kmD1_MTD_20141016_bil.bil",(/621,1405/),"float")
> dat at _FillValue=-9999
> wks = gsn_open_wks("png","bil-test")
> res = True
> res at cnFillOn = True
> res at cnLinesOn = False
> res at cnLineLabelsOn = False
> res at cnFillMode = "rasterfill"
> res at mpMaxLatF=49.916666666669
> res at mpMinLatF= res at mpMaxLatF -  .041666666667 * 621
> res at mpMinLonF= -125.000000000000
> res at mpMaxLonF = res at mpMinLonF + .041666666667 * 1405
> res at mpLimitMode = "latlon"
> res at tfDoNDCOverlay = True
> res at tiMainString = "PRISM_ppt_early_4kmD1_MTD_20141016_bil.bil"
> plot = gsn_csm_contour_map(wks,dat(::-1,:),res)
>
>  -dave
>
>
>
>
>
>
>
>
> On Fri, Oct 17, 2014 at 11:08 AM, Rick Brownrigg <brownrig at ucar.edu>
> wrote:
> > Hi Daniel
> >
> > "Band-Interleaved Format"  My understanding of the format is that the
> .bil
> > file itself is just a "brick of floats" (or integers, bytes, etc.) that
> is
> > MxNxP, where P is the number of bands that make up this image. It is
> > organized as all of the floats (ints) of the first row for band-1,
> followed
> > by the floats for first row's 2nd ban, ..., the floats of first row's Pth
> > band, then likewise for subsequent rows, ...
> >
> > In your example, there's only 1 band. We see that it is 621x1405,
> comprised
> > of 32-bit floats. Hence the first row is 5620 bytes in length:  1405 *
> > sizeof(float) = 1405 * 4 = 5620.  This should be relatively
> straightforward
> > to read:
> >
> > http://ncl.ucar.edu/Applications/r-binary.shtml
> >
> > Its not clear to me from the header whether the first row is the
> > bottom/southern-most, or the top/northern-most.
> >
> > Does that help?
> > Rick
> >
> >
> > On Fri, Oct 17, 2014 at 10:37 AM, Daniel Barandiaran
> > <dbarandiaran at gmail.com> wrote:
> >>
> >> Has anyone dealt with these files?  I've done some work with binary
> files
> >> before, but I am no pro by any means.  I've read a little about the data
> >> format of these .bil files, but I'm still not sure about exactly how
> these
> >> files are formatted.  They have a file header, which contains the
> following:
> >>
> >> BYTEORDER      I
> >> LAYOUT         BIL
> >> NROWS          621
> >> NCOLS          1405
> >> NBANDS         1
> >> NBITS          32
> >> BANDROWBYTES   5620
> >> TOTALROWBYTES  5620
> >> PIXELTYPE      FLOAT
> >> ULXMAP         -125
> >> ULYMAP         49.9166666666687
> >> XDIM           0.04166666666667
> >> YDIM           0.04166666666667
> >> NODATA         -9999
> >>
> >> any help would be appreciated!
> >>
> >> --
> >> Danny Barandiaran
> >> Department of Plants, Soils, and Climate
> >> Utah State University
> >>
> >>
> >>
> >> _______________________________________________
> >> ncl-talk mailing list
> >> List instructions, subscriber options, unsubscribe:
> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >>
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>



-- 
Danny Barandiaran
Department of Plants, Soils, and Climate
Utah State University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141017/a30c9fe6/attachment.html 


More information about the ncl-talk mailing list