Import HDF4 Files Interactively

The HDF Import Tool is a graphical user interface that you can use to navigate through HDF4 or HDF-EOS files and import data from them. Importing data using the HDF Import Tool involves these steps:

The following sections provide more detail about each of these steps.

Step 1: Opening an HDF4 File in the HDF Import Tool

Open an HDF4 or HDF-EOS file in MATLAB® using one of the following methods:

  • On the Home tab, in the Variable section, click Import Data. If you select an HDF4 or HDF-EOS file, the MATLAB Import Wizard automatically starts the HDF Import Tool.

  • Start the HDF Import Tool by entering the hdftool command at the MATLAB command line:

    hdftool
    

    This opens an empty HDF Import Tool. To open a file, click the Open option on the HDFTool File menu and select the file you want to open. You can open multiple files in the HDF Import Tool.

  • Open an HDF or HDF-EOS file by specifying the file name with the hdftool command on the MATLAB command line:

    hdftool('example.hdf')
    

Viewing a File in the HDF Import Tool

When you open an HDF4 or HDF-EOS file in the HDF Import Tool, the tool displays the contents of the file in the Contents pane. You can use this pane to navigate within the file to see what data sets it contains. You can view the contents of HDF-EOS files as HDF data sets or as HDF-EOS files. The icon in the contents pane indicates the view, as illustrated in the following figure. Note that these are just two views of the same data.

Step 2: Selecting a Data Set in an HDF File

To import a data set, you must first select the data set in the contents pane of the HDF Import Tool. Use the Contents pane to view the contents of the file and navigate to the data set you want to import.

For example, the following figure shows the data set Example SDS in the HDF file selected. Once you select a data set, the Metadata panel displays information about the data set and the importing and subsetting pane displays subsetting options available for this type of HDF object.

Step 3: Specifying a Subset of the Data (Optional)

When you select a data set in the contents pane, the importing and subsetting pane displays the subsetting options available for that type of HDF object. The subsetting options displayed vary depending on the type of HDF object. For more information, see Using the HDF Import Tool Subsetting Options.

Step 4: Importing Data and Metadata

To import the data set you have selected, click the Import button, bottom right corner of the Importing and Subsetting pane. Using the Importing and Subsetting pane, you can

  • Specify the name of the workspace variable — By default, the HDF Import Tool uses the name of the HDF4 data set as the name of the MATLAB workspace variable. In the following figure, the variable name is Example_SDS. To specify another name, enter text in the Workspace Variable text box.

  • Specify whether to import metadata associated with the data set — To import any metadata that might be associated with the data set, select the Import Metadata check box. To store the metadata, the HDF Import Tool creates a second variable in the workspace with the same name with “_info” appended to it. For example, if you select this check box, the name of the metadata variable for the data set in the figure would be Example_SDS_info.

  • Save the data set import command syntax — The Dataset import command text window displays the MATLAB command used to import the data set. This text is not editable, but you can copy and paste it into the MATLAB Command Window or a text editor for reuse.

The following figure shows how to specify these options in the HDF Import Tool.

Step 5: Closing HDF Files and the HDF Import Tool

To close a file, select the file in the contents pane and click Close File on the HDF Import Tool File menu.

To close all the files open in the HDF Import Tool, click Close All Files on the HDF Import Tool File menu.

To close the tool, click Close HDFTool in the HDF Import Tool File menu or click the Close button in the upper right corner of the tool.

If you used the hdftool syntax that returns a handle to the tool,

h = hdftool('example.hdf')

you can use the close(h) command to close the tool from the MATLAB command line.

Using the HDF Import Tool Subsetting Options

Note

The HDF Import Tool will be removed in a future release.

When you select a data set, the importing and subsetting pane displays the subsetting options available for that type of data set. The following sections provide information about these subsetting options for all supported data set types. For general information about the HDF Import tool, see Import HDF4 Files Interactively.

Note

To use these data subsetting options effectively, you must understand the HDF and HDF-EOS data formats. Therefore, use this documentation in conjunction with the HDF documentation (www.hdfgroup.org) and the HDF-EOS documentation (www.hdfeos.org).

HDF Scientific Data Sets (SD)

The HDF scientific data set (SD) is a group of data structures used to store and describe multidimensional arrays of scientific data. Using the HDF Import Tool subsetting parameters, you can import a subset of an HDF scientific data set by specifying the location, range, and number of values to be read along each dimension.

The subsetting parameters are:

  • Start — Specifies the position on the dimension to begin reading. The default value is 1, which starts reading at the first element of each dimension. The values specified must not exceed the size of the relevant dimension of the data set.

  • Increment — Specifies the interval between the values to read. The default value is 1, which reads every element of the data set.

  • Length — Specifies how much data to read along each dimension. The default value is the length of the dimension, which causes all the data to be read.

HDF Vdata

HDF Vdata data sets provide a framework for storing customized tables. A Vdata table consists of a collection of records whose values are stored in fixed-length fields. All records have the same structure and all values in each field have the same data type. Each field is identified by a name. The following figure illustrates a Vdata table.

You can import a subset of an HDF Vdata data set in the following ways:

  • Specifying the name of the field that you want to import

  • Specifying the range of records that you want to import

The following figure shows how you specify these subsetting parameters for Vdata.

HDF-EOS Grid Data

In HDF-EOS Grid data, a rectilinear grid overlays a map. The map uses a known map projection. The HDF Import Tool supports the following mutually exclusive subsetting options for Grid data:

To access these options, click the Subsetting method menu in the importing and subsetting pane.

Direct Index.  You can import a subset of an HDF-EOS Grid data set by specifying the location, range, and number of values to be read along each dimension.

Each row represents a dimension in the data set and each column represents these subsetting parameters:

  • Start — Specifies the position on the dimension to begin reading. The default value is 1, which starts reading at the first element of each dimension. The values specified must not exceed the size of the relevant dimension of the data set.

  • Increment — Specifies the interval between the values to read. The default value is 1, which reads every element of the data set.

  • Length — Specifies how much data to read along each dimension. The default value is the length of the dimension, which causes all the data to be read.

Geographic Box.  You can import a subset of an HDF-EOS Grid data set by specifying the rectangular area of the grid that you are interested in. To define this rectangular area, you must specify two points, using longitude and latitude in decimal degrees. These points are two corners of the rectangular area. Typically, Corner 1 is the upper-left corner of the box, and Corner 2 is the lower-right corner of the box.

Optionally, you can further define the subset of data you are interested in by using Time parameters (see Time) or by specifying other User-Defined subsetting parameters (see User-Defined).

Interpolation.  Interpolation is the process of estimating a pixel value at a location in between other pixels. In interpolation, the value of a particular pixel is determined by computing the weighted average of some set of pixels in the vicinity of the pixel.

You define the region used for bilinear interpolation by specifying two points that are corners of the interpolation area:

  • Corner 1 – Specify longitude and latitude values in decimal degrees. Typically, Corner 1 is the upper-left corner of the box.

  • Corner 2 — Specify longitude and latitude values in decimal degrees. Typically, Corner 2 is the lower-right corner of the box

Pixels.  You can import a subset of the pixels in a Grid data set by defining a rectangular area over the grid. You define the region used for bilinear interpolation by specifying two points that are corners of the interpolation area:

  • Corner 1 – Specify longitude and latitude values in decimal degrees. Typically, Corner 1 is the upper-left corner of the box.

  • Corner 2 — Specify longitude and latitude values in decimal degrees. Typically, Corner 2 is the lower-right corner of the box

Tile.  In HDF-EOS Grid data, a rectilinear grid overlays a map. Each rectangle defined by the horizontal and vertical lines of the grid is referred to as a tile. If the HDF-EOS Grid data is stored as tiles, you can import a subset of the data by specifying the coordinates of the tile you are interested in. Tile coordinates are 1-based, with the upper-left corner of a two-dimensional data set identified as 1,1. In a three-dimensional data set, this tile would be referenced as 1,1,1.

Time.  You can import a subset of the Grid data set by specifying a time period. You must specify both the start time and the stop time (the endpoint of the time span). The units (hours, minutes, seconds) used to specify the time are defined by the data set.

Along with these time parameters, you can optionally further define the subset of data to import by supplying user-defined parameters.

User-Defined.  You can import a subset of the Grid data set by specifying user-defined subsetting parameters.

When specifying user-defined parameters, you must first specify whether you are subsetting along a dimension or by field. Select the dimension or field by name using the Dimension or Field Name menu. Dimension names are prefixed with the characters DIM:.

Once you specify the dimension or field, you use Min and Max to specify the range of values that you want to import. For dimensions, Min and Max represent a range of elements. For fields, Min and Max represent a range of values.

HDF-EOS Point Data

HDF-EOS Point data sets are tables. You can import a subset of an HDF-EOS Point data set by specifying field names and level. Optionally, you can refine the subsetting by specifying the range of records you want to import, by defining a rectangular area, or by specifying a time period. For information about specifying a rectangular area, see Geographic Box. For information about subsetting by time, see Time.

HDF-EOS Swath Data

HDF-EOS Swath data is data that is produced by a satellite as it traces a path over the earth. This path is called its ground track. The sensor aboard the satellite takes a series of scans perpendicular to the ground track. Swath data can also include a vertical measure as a third dimension. For example, this vertical dimension can represent the height above the Earth of the sensor.

The HDF Import Tool supports the following mutually exclusive subsetting options for Swath data:

To access these options, click the Subsetting method menu in the Importing and Subsetting pane.

Direct Index.  You can import a subset of an HDF-EOS Swath data set by specifying the location, range, and number of values to be read along each dimension.

Each row represents a dimension in the data set and each column represents these subsetting parameters:

  • Start — Specifies the position on the dimension to begin reading. The default value is 1, which starts reading at the first element of each dimension. The values specified must not exceed the size of the relevant dimension of the data set.

  • Increment — Specifies the interval between the values to read. The default value is 1, which reads every element of the data set.

  • Length — Specifies how much data to read along each dimension. The default value is the length of the dimension, which causes all the data to be read.

Geographic Box.  You can import a subset of an HDF-EOS Swath data set by specifying the rectangular area of the grid that you are interested in and by specifying the selection Mode.

You define the rectangular area by specifying two points that specify two corners of the box:

  • Corner 1 — Specify longitude and latitude values in decimal degrees. Typically, Corner 1 is the upper-left corner of the box.

  • Corner 2 — Specify longitude and latitude values in decimal degrees. Typically, Corner 2 is the lower-right corner of the box.

You specify the selection mode by choosing the type of Cross Track Inclusion and the Geolocation mode. The Cross Track Inclusion value determines how much of the area of the geographic box that you define must fall within the boundaries of the swath.

Select from these values:

  • AnyPoint — Any part of the box overlaps with the swath.

  • Midpoint — At least half of the box overlaps with the swath.

  • Endpoint — All of the area defined by the box overlaps with the swath.

The Geolocation Mode value specifies whether geolocation fields and data must be in the same swath.

Select from these values:

  • Internal — Geolocation fields and data fields must be in the same swath.

  • External — Geolocation fields and data fields can be in different swaths.

Time.  You can optionally also subset swath data by specifying a time period. The units used (hours, minutes, seconds) to specify the time are defined by the data set

User-Defined.  You can optionally also subset a swath data set by specifying user-defined parameters.

When specifying user-defined parameters, you must first specify whether you are subsetting along a dimension or by field. Select the dimension or field by name using the Dimension or Field Name menu. Dimension names are prefixed with the characters DIM:.

Once you specify the dimension or field, you use Min and Max to specify the range of values that you want to import. For dimensions, Min and Max represent a range of elements. For fields, Min and Max represent a range of values.

HDF Raster Image Data

For 8-bit HDF raster image data, you can specify the colormap.