Close

Service Interruption

The NSIDC Web site and data services are currently having intermittent problems and may be unavailable. We are working to restore these services as soon as possible and apologize for any inconvenience this may cause. Please contact NSIDC User Services for assistance.

Hierarchical Data Format - Earth Observing System (HDF-EOS)



Converting from HDF to ASCII Format


Table of Contents


Use the following links to access the procedures on this Web page:

Dumping HDF Metadata Into ASCII Format Using the ncdump Utility

UNIX/Linux Users

Windows NT/98/2000/XP Users

Example


Dumping HDF Metadata Into ASCII Format Using the ncdump Utility

The HDF Group provides various utilities for viewing the contents of Hierarchical Data Format (HDF) files and extracting the raster, binary, or ASCII objects. The ncdump utility provides a simple way to dump HDF data and metadata into ASCII format. The ncdump -H command provides instructions for using ncdump. We provide more comprehensive yet simple instructions for extracting data and metadata from HDF files.


UNIX/Linux Users

Download HDF Libraries from The HDF Group Web Site

HDF libraries are required to run ncdump on UNIX/Linux platforms. The following instructions assume you are using either sh, csh, or tcsh on a UNIX/Linux system.

  1. Go to the szip compression external libraries pre-compiled binaries at:
    ftp://ftp.hdfgroup.org/lib-external/szip/2.0/bin/.

  2. Follow the link to the directory for your operating system and download the corresponding "noenc" file to your home directory.
    Example: szip2.0-linux-noenc.tar.gz

  3. Gunzip the file you downloaded using the following command:

    gunzip szip2.0-linux-noenc.tar.gz

  4. Untar the resulting tar file using the following command:

    tar xvf szip2.0-linux-noenc.tar

  5. Note: This creates the directory szip2.0-linux-noenc in your home directory.

  6. Check to see if you have the environment variable LD_LIBRARY_PATH defined by typing:

    echo $LD_LIBRARY_PATH

  7. Choose one of the following steps:
  1. If the environment variable LD_LIBRARY_PATH is defined, add the szip library directory to your existing LD_LIBRARY_PATH environment variable by typing:

    setenv LD_LIBRARY_PATH LD_LIBRARY_PATH\:$HOME/szip2.0-linux-noenc/lib

  2. If the environment variable LD_LIBRARY_PATH is not defined, the following message displays on your screen: LD_LIBRARY_PATH:Undefined variable, set the LD_LIBRARY_PATH environment variable to the szip library directory by typing:

    setenv LD_LIBRARY_PATH $HOME/szip2.0-linux-noenc/lib

Download ncdump from The HDF Group Web Site

  1. Go to Pre-Compiled Binary Distributions.

  2. Select the appropriate directory for your platform.

  3. Follow the link to the utilities directory.

  4. Download ncdump to your local drive using an ftp application.

  5. Type the following command to ensure the owner and the group of the file have read, write, and execute permission for running ncdump:

  6. chmod 775 ncdump

Dump HDF to ASCII Format

  1. Choose one of the following steps:
  1. To dump the entire contents of an HDF file to ASCII format, type the following command:

    ncdump <inputfilename.hdf>

  2. To dump one data variable from the HDF file to ASCII format, type the following command:

    ncdump –v <variable name> <inputfilename.hdf>

    Note 1: Use double quotes around the variable name if it consists of two or more words, for example "Sea Ice by Reflectance."

  3. To dump only the metadata information to the screen, type the following command:

    ncdump -h <inputfilename.hdf> | more

  4. To dump this metadata information to an output file named ascii.out, type the following command:

    ncdump -h <inputfilename.hdf> > ascii.out

Windows NT/98/2000/XP Users

Download ncdump from The HDF Group Web Site

  1. Go to: ftp://ftp.hdfgroup.org/HDF/HDF_Current/bin/windows/.

  2. Download the ncdump.exe file to your local drive.

  3. For Windows XP users, you must download three library files, zlib1.dll, szlibdll.dll, and szlibdll.lib, to the same directory where you downloaded the ncdump.exe file.

  4. Download zlib1.2.dll

    Download szlibdll.dll and szlibdll.lib

  5. Choose one of the following steps to open a Windows DOS command prompt window:
  1. On your PC, select Start --> Run --> type the word Command in the dialog box.

  2. On your PC, select Start --> All Programs --> Accessories --> Command prompt.
  1. Change directories in the command prompt window until you are in the directory with the ncdump executable. Be sure the HDF file is also in the same directory.

Dump HDF to ASCII Format

  1. Choose one of the following steps:
  1. To dump the entire contents of an HDF file to ASCII format, type the following command:

    ncdump <inputfilename.hdf>

  2. To dump one data variable from the HDF file to ASCII format, type the following command:

    ncdump –v <variable name> <inputfilename.hdf>

    Note 1: Use double quotes around the variable name if it consists of two or more words, for example "Sea Ice by Reflectance."

  3. To dump only the metadata information to the screen, type the following command:

    ncdump -h <inputfilename.hdf> | more

  4. To dump this metadata information to an output file named ascii.out, type the following command:

    ncdump -h <inputfilename.hdf> > ascii.out

    Note: Either Microsoft Word or WordPad can read the metadata file. If your computer does not automatically open the file with one of these applications, you may have to manually open the file after starting Word or WordPad.

Example

This example uses the AMSR-E/Aqua Daily L3 6.25 km 89 GHz Brightness Temperature (Tb) Polar Grids (AE_SI6) data set in HDF-EOS format. We illustrate the use of ncdump to extract the metadata information from the HDF file header.

  1. Download the following AE_S16 file to the directory containing ncdump.

    AMSR_E_L3_SeaIce6km_B06_20070307.hdf

    Note: You may be able to right-click the mouse over the file name to download it. Do not left-click the file name, as this will display the HDF code in your browser.

  2. Perform one of the following steps:
  1. At a UNIX or Microsoft Windows MS-DOS command line, type the following command:

    ncdump -h AMSR_E_L3_SeaIce6km_B06_20070307.hdf | more

  2. To dump the header information to an output file named ascii.out, type the following command:

    ncdump -h AMSR_E_L3_SeaIce6km_B06_20070307.hdf > ascii.out
  1. Download the ASCII output file to your local drive by clicking on the following link:

    ascii.out

  2. Note 1: The output of the ncdump file consists of the following information:

    Dimensions of the data arrays
    Names of the data variables
    List of global attributes and their values

    Note 2: Specific metadata descriptions for AE_S16 are available in the product documentation.