The hdfeos2netcdf is a tool that converts an HDF-EOS2 file or an HDF-EOS5 file to an netCDF file. This program can convert only grid and swath data; point data cannot be converted. The format of netCDF files this program creates is netCDF-3, not netCDF-4.
This program requires several libraries:
HDF4
,
HDF5
, HDF-EOS2,
HDF-EOS5
,
netCDF-3
and
HE2HE5
.
Users need to set paths to those libraries in the
Makefile
. Then, typing make
will make a binary hdfeos2netcdf
.
Users need to be careful when they build the HDF4 library because the HDF4 library may conflict with
the
netCDF
library. Since part of
netCDF
API is implemented in HDF4 library, both libraries
export exactly same symbols, which results in linker errors. To prevent this error,
users need to specify
--disable-netcdf
switch when the HDF4 library is configured.
If
netCDF-4
code is used with the HDF5 library to build netCDF library, users may need to add
-lhdf5_hl
flag to HDFLIBS
in Makefile
.
This program takes two command-line arguments: the HDF-EOS input file and the netCDF output file. If the input file contains point data, an error will arise.
As README
file included in the package explains, the structural difference between
HDF-EOS and netCDF (classic) is an issue; (classic) netCDF format does not allow multiple groups
while the input HDF-EOS file can contain multiple grids and swaths. For example, a problem arises
when the input file contains two grids and they have data fields with the same name.
This program avoids this problem by mangling variable names; grid name is prefixed to the variable name.
Another issue is related to the projection of grid data in HDF-EOS files. HDF-EOS grid data saves space by keeping only a few parameters instead of entire longitude and latitude data. This method does not lose any information because the HDF-EOS library can calculate longitude and latitude values from those parameters. However, netCDF requires latitude and longitude data to be present. To that end, this program calculates longitude and latitude values, and stores them at the output file. However, this longitude/latitude conversion has limitation; the generated longitude and latitude are always one-dimensional. If the projection method needs two-dimensional longitude and latitude values, the conversion is not complete.
In swath data, longitude and latitude variables are usually two-dimensional, which is not supported by netCDF format. By following CF conventions, this program can generate coordinates attribute, which is required by CF conventions, to variables. However, we noticed that the coordinates attribute is written only when dimension maps are not used in swath.
Dimension maps in HDF-EOS swath data also introduce a problem. With dimension maps, data fields and geo-location fields have different sizes. This is not supported by netCDF format. A possible solution to resolve this issue is to generate adjusted geo-location fields, but this program does not do.
We found a few problems while testing this program. First, this program may crash while converting grid attributes of string type. Second, this program may not find dimensions of grid data, which aborts the conversion. Also, we found a potential problem that may introduce buffer-overrun. To avoid this problem, users may need to apply the following changes: