Read data from HDF4 or HDF-EOS file
data = hdfread(filename, datasetname)
data = hdfread(hinfo)
data = hdfread(...,param,value,...)
data = hdfread(filename,EOSname,param,value,...)
[data,map] = hdfread(...)
data = hdfread(filename, datasetname)
returns
all the data in the data set specified by datasetname
from
the HDF4 or HDF-EOS file specified by filename
.
To determine the name of a data set in an HDF4 file, use the hdfinfo
function.
Note
hdfread
can be used on Version 4.x HDF
files or Version 2.x HDF-EOS files. To read data from an HDF5 file,
use h5read
.
data = hdfread(hinfo)
returns
all the data in the data set specified by the structurehinfo
,
returned by the hdfinfo
function. Specify the field
in the hinfo
structure that relates to a particular
type of data set, and use indexing to specify which data set, when
there are more than one. See Specify data set to read for more information.
data = hdfread(...,param,value,...)
returns
subsets of the data according to the specified parameter and value
pairs. See the tables below to find the valid parameters and values
for different types of data sets.
data = hdfread(filename,EOSname,param,value,...)
subsets
the data field from the HDF-EOS point, grid, or swath specified by EOSname
.
[data,map] = hdfread(...)
returns
the image data
and the colormap map
for
an 8-bit raster image.
The following tables show the subsetting parameters that can
be used with the hdfread
function for certain
types of HDF4 data. These data types are
Note the following:
If a parameter requires multiple values, use a cell
array to store the values. For example, the 'Index'
parameter
requires three values: start
, stride
,
and edge
. Enclose these values in curly braces
as a cell array.
hdfread(..., 'Index', {start,stride,edge})
All values that are indices are 1-based.
When you are working with HDF SD files, hdfread
supports
the parameters listed in this table.
Parameter | Description |
---|---|
| Three-element cell array,
|
For example, this code reads the data set Example SDS
from
the HDF file example.hdf
. The 'Index'
parameter
specifies that hdfread
start reading data at the
beginning of each dimension, read until the end of each dimension,
but only read every other data value in the first dimension.
data = hdfread('example.hdf','Example SDS','Index',{[],[2 1],[]})
When you are working with HDF Vdata files, hdfread
supports
these parameters.
Parameter | Description |
---|---|
| Character vector or string scalar specifying the name of the field to be read. When specifying multiple field names, use a cell array of character vectors or a string array. |
| 1-based number specifying the record from which to begin reading |
| Number specifying the total number of records to read |
For example, this code reads the Vdata set Example
Vdata
from the HDF file example.hdf
.
data = hdfread('example.hdf','Example Vdata','FirstRecord', 2,'NumRecords', 5)
When you are working with HDF-EOS grid data, hdfread
supports
three types of parameters:
Required parameters
Optional parameters
Mutually exclusive parameters — You can only
specify one of these parameters in a call to hdfread
,
and you cannot use these parameters in combination with any optional
parameter.
Parameter | Description |
---|---|
Required Parameter | |
| Character vector or string scalar specifying the field to be read. You can specify only one field name for a Grid data set. |
Mutually Exclusive Optional Parameters | |
| Three-element cell array,
Default:
Default:
Default: An array containing the lengths of the corresponding dimensions |
| Two-element cell array, |
| Two-element cell array, Note:
This is the pixel equivalent of reading a |
| Vector specifying the coordinates of the tile to read, for HDF-EOS Grid files that support tiles |
Optional Parameters | |
| Two-element cell array, |
| Two-element cell array, |
| Two-element cell array,
|
For example,
data = hdfread('grid.hdf','PolarGrid','Fields','ice_temp','Index', {[5 10],[],[15 20]})
When you are working with HDF-EOS Point data, hdfread
has
two required parameters and three optional parameters.
Parameter | Description |
---|---|
Required Parameters | |
| Character vector or string scalar containing the name of the data set field to be read. For multiple field names, use a cell array of character vectors or a string array. |
| 1-based number specifying which level to read from in an HDF-EOS Point data set |
Mutually Exclusive Optional Parameters | |
| Two-element cell array, |
| Vector specifying the record numbers to read |
| Two-element cell array, |
For example,
hdfread(...,'Fields',{field1, field2},... 'Level',level,'RecordNumbers',[1:50, 200:250])
When you are working with HDF-EOS Swath data, hdfread
supports
three types of parameters:
Required parameters
Optional parameters
Mutually exclusive
You can only use one of the mutually exclusive parameters in
a call to hdfread
, and you cannot use these parameters
in combination with any optional parameter.
Parameter | Description |
---|---|
Required Parameter | |
| Character vector or string scalar containing the name of the data set field to be read. You can specify only one field name for a Swath data set. |
Mutually Exclusive Optional Parameters | |
| Three-element cell array,
|
| Three-element cell array,
|
Optional Parameters | |
| Three-element cell array,
|
| Two-element cell array,
|
For example,
hdfread('swath.hdf', 'Example Swath', 'Fields', 'Temperature', ... 'Time', {5000, 6000, 'midpoint'})