[R-sig-Geo] Reading National Snow and Ice Data Center binary files

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Oct 12 14:04:32 CEST 2011


On Wed, Oct 12, 2011 at 11:08 AM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:

>  Annoyingly I don't think gdal's raw data vrt system can find out the
> number of pixels across/down the raster - you have to code them into
> the .vrt file. I reckon with a bit of unix (or in extremis, C code)
> craftiness it would be possible to get the info from the header of the
> .bin file and write the relevant .vrt file...

The data format details tells is the files only come in a limited
number of sizes. I grabbed a .bin file and wrote this .vrt file to sit
next to it:

<VRTDataset rasterXSize="304" rasterYSize="448">
  <VRTRasterBand dataType="Byte" band="1" subClass="VRTRawRasterBand">
    <SourceFilename relativetoVRT="1">nt_20111010_f17_nrt_n.bin</SourceFilename>
    <ImageOffset>300</ImageOffset>
    <PixelOffset>1</PixelOffset>
    <LineOffset>304</LineOffset>
  </VRTRasterBand>
</VRTDataset>

Then in R:

require(rgdal)
 ice=readGDAL("nt_20111010_f17_nrt_n.vrt")
 image(ice)

and there's Greenland, and various other bits of rapidly melting ice...

Hope this helps - the important bits of the .vrt file are the 300
offset the raster X and Y size and LineOffset(which =XSize) and
obviously the filename...

I'd write a script to create these .vrt files and then convert
everything to a standard format like GeoTiff... Note you'll have to
add the projection info on manually... etc etc etc.

Barry



More information about the R-sig-Geo mailing list