The IDL program "hdfeos2bin.pro," written by Terry Haran of the National Snow and Ice Data Center, extracts data arrays from an HDF-EOS file and writes the arrays to separate flat binary data files. Currently, this program has been tested with Moderate-Resolution Imaging Spectroradiometer (MODIS) sea ice and snow cover products at NSIDC; however, it is designed to work with any HDF-EOS file.
The program "hdfeos2bin.pro" calls several subprograms that read swath or grid input data from HDF-EOS files and writes the output data to flat binary files. While this program has limited capabilities, it effectively demonstrates the use of HDF-EOS library calls without the need for installing and linking to HDF and HDF-EOS libraries, because IDL effectively provides these libraries as built-in functions and procedures. The "hdfeos2bin.pro" program contains detailed documentation within the code.
1. Download hdfeos2bin.pro and the following subprograms to the directory containing your HDF-EOS files. (Note: you may be able to right-click your mouse over the file names to download them.)
process_grid.pro
process_grid_field.pro
process_swath.pro
process_swath_field.pro
write_field.pro
Following is an example MODIS level 2 (swath) sea ice file (MOD29) in HDF-EOS format. We illustrate the use of "hdfeos2bin.pro" to extract data arrays from the HDF-EOS file and write the arrays to separate flat binary files.
MOD29.A2000145.1850.002.2000.hdf
1. Download the file above to your directory containing "hdfeos2bin.pro". (Note: you may be able to right-click your mouse over the file name to download it. Don't left-click the file name, as this will display the HDF code in your browser.)
You should change the current directory to where the HDF files reside before invoking IDL. Windows NT/98/2000 users may be unable to do this if they invoke IDL by clicking an icon. The IDL command "printd" displays the current directory if you are unsure. If you discover you need to change the current directory while in IDL, type:
cd, 'working directory' (where the HDF files reside)
2. Type: hdfeos2bin, '*.hdf' or hdfeos2bin, '*.hdf', /verbose (for the verbose option)
3. After "hdfeos2bin.pro" and its subprograms run, list the files in your current directory. You will see a new directory called "MOD29.A2000145.1850.002.2000.hdf.dir". Go to that directory. You will see the following binary files:
Combined_Sea_Ice_u1_01354_02030.img
Ice_Surface_Temperature_PixelQA_u1_01354_02030.img
Ice_Surface_Temperature_u2_01354_02030.img
Latitude_f4_00271_00406.img
Longitude_f4_00271_00406.img
Sea_Ice_by_IST_u1_01354_02030.img
Sea_Ice_by_Reflectance_PixelQA_u1_01354_02030.img
Sea_Ice_by_Reflectance_u1_01354_02030.img
File names give the dimensions of the binary arrays (1354 columns by 2030 rows, or 271 columns by 406 rows, in this example). The files containing "u1" consist of unsigned 1-byte integers. The "u2" indicates unsigned 2-byte integers, and "f4" indicates 4-byte (single-precision) floating-point numbers.
4. Follow the links below for samples of each of the MODIS products that NSIDC supports. Each file contains data for the same date (1 May 2001) for roughly the same area (Alaska and the Beaufort Sea).
MOD10_L2_A2001121_0005_003_2001240182349.hdf
(MODIS/Terra Snow Cover 5-Min L2 Swath 500m V003)MOD10A1_A2001121_h10v02_003_2001241142912.hdf
(MODIS/Terra Snow Cover Daily L3 Global 500m ISIN Grid V003)MOD10A2_A2001121_h10v02_003_2001250031450.hdf
(MODIS/Terra Snow Cover 8-Day L3 Global 500m ISIN Grid V001)MOD29_A2001121_0005_003_2001240182453.hdf
(MODIS/Terra Sea Ice Extent 5-Min L2 Swath 1km V003)MOD29P1D_A2001121_h08v07_003_2001241124613.hdf
(MODIS/Terra Sea Ice Extent Daily L3 Global 1km EASE-Grid Day V003)MOD29P1N_A2001121_h08v07_003_2001241122208.hdf
(MODIS/Terra Sea Ice Extent Daily L3 Global 1km EASE-Grid Night V003)
5. Type: hdfeos2bin, '*.hdf' or hdfeos2bin, '*.hdf', /verbose (for the verbose option)
6. Each file will have a corresponding directory containing its own flat binary files.