HDF-EOS2 Dumper

The HDF-EOS2 Dumper is a command-line program that dumps information in an HDF-EOS2 file. It is mainly used for dumping latitude and longitude values of different grids and swaths. It can also dump the number of grids and swaths as well as their names and data. The main advantage of this program is that it can generate the actual lat and lon values in ASCII when different projections, like Sinusoidal (SNSOID) and Space Oblique Mercator (SOM), and swath dimension maps are used. The plain text lat/lon values can be easily loaded into other software such as MATLAB and IDL that cannot resolve projection information from HDF-EOS2 file.

The HDF-EOS2 library uses the U.S. Geological Survey General Cartographic Transformation Package (GCTP) to define grid structures. Thus, HDF-EOS2 data files have one of the following GCTP projections:

Code Projection Description
GEOGeographic
PSPolar Stereographic
LAMAZLambert Azimuthal Equal Area
SNSOIDSinusoidal
SOMSpace Oblique Mercator
CEACylindrical Equal-Area (for EASE grid with corners in meters)

The above table contains the most common projections used in NASA HDF-EOS2 files. Please see 6.5.1 GCTP Projection Codes in [1] for the complete list of projections.

Download

We provide the binaries on the following platforms.

Platform Binary Checksum
Windows (7 or newer) eos2dump.exe SHA256
Mac OS X (Mountain Lion or newer) eos2dump SHA256
Linux 2.6 (i386) eos2dump SHA256
Linux 2.6 (x86_64) eos2dump SHA256

If you want to build eos2dump from the source, please download the eos2dump-1.4.0.tar.gz (SHA256) source package.

Build Instruction

Pre-installation Checklist

To build eos2dump from the source, eos2dump requires the HDF-EOS2 library. The HDF-EOS2 library requires HDF4 library and the HDF4 library requires zlib and jpeg.

Building with Makefile Template

To build eos2dump on Unix systems, one needs to modify the Makefile template in the source distribution. The following library paths should be edited first:

ZLIB_DIR=/path/to/install/prefix/of/zlib
SZIP_DIR=/path/to/install/prefix/of/szip
JPEG_DIR=/path/to/install/prefix/of/jpeg6b
HDF4_DIR=/path/to/install/prefix/of/hdf4
HDFEOS2_DIR=/path/to/install/prefix/of/hdfeos
Figure 1. Required modification of paths in Makefile template

With the edited Makefile, one can build eos2dump binary by issuing make command.

Building with CMake

Please note that builiding with CMake on Windows may not work for the latest Visual Studio 2017. We recommend using MSYS2 for building HDF-EOS2 dumper.

To build eos2dump using CMake (on Windows), one needs to create include/ and lib/ sub-directories at the unpacked source directory and put all (zlib, szip, jpeg, hdf4, hdf-eos2) dependency headers and libraries there. Then, run cmake . and cmake --build . at the command line. The eos2dump(.exe) will be created under bin/(Debug/) directory.

On Windows, you will need depedent DLL files (e.g., hdf.dll, mfhdf.dll, jpeg.dll, etc.) under bin/Debug/ directory to test the newly-compiled bin/Debug/eos2dump.exe binary.

Usage

This program takes several command-line arguments: options, file name, grid or swath name, and SOM block number if SOM projection is used. It reads the input file and dumps all the latitude and/or longitude values for the specified grid/swath name in ASCII. If there is only one grid or swath available, you don't need to specify its name. If the file has multiple grids or swaths, a specific grid/swath name is expected as an argument. The program will use that name by default and dumps the corresponding lat and lon values. It will generate error message and terminate the program if no grid or swath name specified if more than one is available.

When the desired grid contains SOM projection, you need to specify the SOM block number you want to dump as an additional argument after the grid name argument. The dimension number should be between 1 and 180. If you want to dump lat/lon for all block dimensions, specify all option after the grid name. When only one grid exists, you don't need to specify the grid name, but you are also required to give the SOM block number you want to dump.

The HDF-EOS2 Dumper tool provides the following command line options:

$eos2dump [-12acdghmorvV35746890i]file[grid/swath_name][som_block]
Figure 2. Command line options of the HDF-EOS2 Dumper

The names and functions of all the supported options are listed below.

Examples

We provide several examples to show how to use this program to dump lat and lon values for various NASA HDF-EOS2 files.

Example 1

The first example is to dump latitude values of a swath object called L2_Standard_cloud-cleared_radiance_product in an HDF-EOS2 file AIRS.2002.12.31.001.L2.CC_H.v4.0.21.0.G06100185050.hdf. This file doesn't contain swath dimension map. The latitude is 45x30 array, and its type is 64-bit floating-point.

In the shell, one can issue the following command:

$eos2dump -c1mAIRS.2002.12.31.001.L2.CC_H.v4.0.21.0.G06100185050.hdf
Figure 3. How to dump latitude from AIRS swath

The -c option tells the dumper to calculate latitude values. The -1 option determines latitude should be printed on the screen. The option -m specifies 5 data are allowed to be shown per line. The second argument specifies the name of the HDF-EOS2 file. The third argument is omitted, since there is only one swath L2_Standard_cloud-cleared_radiance_product in this file. The program will use it as the default swath name and dump the corresponding lat data.

The output of this program is shown below:

-71.0091, -70.9504, -70.8625, -70.7595, -70.6461,
-70.5277, -70.4059, -70.2819,-70.156, -70.0277,
-69.8982, -69.7672, -69.6335, -69.4951, -69.3532,
-69.2063, -69.0534, -68.8931, -68.7232, -68.5445,
-68.3521, -68.1443, -67.9179, -67.6685, -67.3907,
-67.0772, -66.7182, -66.2973, -65.8015, -65.1923,
...
Figure 4. Result of dumping latitude in AIRS swath

There are five latitude data printed on each line. Since this data file contains data field Latitude, the dumper just reads the lat data from that field and prints them on the screen.

Example 2

The second example is to dump latitude values of a SOM grid object called BlueBand from an HDF-EOS2 file MISR_AM1_GRP_ELLIPSOID_GM_P117_O058421_BA_F03_0024.hdf. Since this file contains SOM projection, latitude and longitude datasets have 180 fixed blocks. For example, the latitude is represented as an 180 x 128 x 512 array in this file. Therefore, we need to specify a block number we want to dump unless you want to dump data from all 180 blocks.

In the shell, one can issue the following command:

$eos2dump -vcm1MISR_AM1_GRP_ELLIPSOID_GM_P117_O058421_BA_F03_0024.hdf BlueBand 20
Figure 5. How to dump latitude of single block from MISR grid

The -v option tells the dumper to add explanatory information to the latitude data, like grid name and file name. The third argument specifies the name of grid whose latitude you want to print on the screen. It will generate error message and stop the program if you don't specify this argument since it contains more than one grid. The fourth argument specifies which block you want to dump. Here we choose the 20th block. If you don't specify it, the program will also generate an error message and stop.

The output of this program is shown below:

HDF-EOS2 file MISR_AM1_GRP_ELLIPSOID_GM_P117_O058421_BA_F03_0024.hdf {

GRID: BlueBand{
84.2115,84.2018, 84.192,84.1822,84.1724,
84.1626,84.1528,84.1431,84.1333,84.1235,
84.1137,84.1039,84.0941,84.0844,84.0746,
84.0648, 84.055,84.0452,84.0354,84.0256,
84.0158,84.0061,83.9963,83.9865,83.9767,
...
}

}
Figure 6. Result of dumping latitude of single block in MISR grid

If you want to dump latitude for all blocks, specify all option after the desired grid name. The command is:

$eos2dump -vcm1MISR_AM1_GRP_ELLIPSOID_GM_P117_O058421_BA_F03_0024.hdf BlueBand all
Figure 7. How to dump latitude of all blocks from MISR grid

The output of the above command is shown below:

HDF-EOS2 file MISR_AM1_GRP_ELLIPSOID_GM_P117_O058421_BA_F03_0024.hdf {

GRID: BlueBand{
66.2263, 66.224,66.2217,66.2195,66.2172,
66.2149,66.2126,66.2103,66.2079,66.2056,
66.2033, 66.201,66.1987,66.1963, 66.194,
66.1917,66.1893, 66.187,66.1846,66.1823,
66.1799,66.1776,66.1752,66.1729,66.1705,
...
}

}
Figure 8. Result of dumping latitude of all blocks in MISR grid

You can also check the projection information by using -o option. Type the following command:

The output of the above command is shown below:

File Size: 208300609
Number of grids: 6
Number of swaths: 0
Number of points: 0
Grid: BlueBand
projection: SOM
griddataclash:
Grid: GreenBand
projection: SOM
griddataclash:
Grid: RedBand
projection: SOM
griddataclash:
Grid: NIRBand
projection: SOM
griddataclash:
Grid: BRF Conversion Factors
projection: SOM
griddataclash:
Grid: GeometricParameters
projection: SOM
griddataclash:
Figure 10. Result of checking the projection information

Example 3

The third example is to dump latitude values of a swath object containing dimension maps called MODIS_SWATH_Type_L1B in an HDF-EOS2 file MYD02HKM.A2010031.0035.005.2010031183706.hdf. This file uses two dimension maps. The lat/lon fields are defined as 2030x1354 array while data fields are defined as either 5x4060x2708 or 2x4060x2708. Please note that data field size 4050x2708 is twice the size of geo field 2030x1354 and that's why eos2dumper provides the -a option.

In the shell, if you want to print the unadjusted (i.e., 2030x1354) latitude, issue the following command:

$eos2dump -c1mMYD02HKM.A2010031.0035.005.2010031183706.hdf
Figure 11. How to dump unadjusted latitude of MODIS swath with dimension maps

The output of the above command is shown below:

-61.0802, -61.1096, -61.1387, -61.1675,-61.196,
-61.2243, -61.2524, -61.2801, -61.3077,-61.335,
-61.3621, -61.3889, -61.4155, -61.4418,-61.468,
-61.4939, -61.5196, -61.5451, -61.5704, -61.5955,
-61.6203,-61.645, -61.6695, -61.6937, -61.7178,
...
Figure 12. Result of dumping the unadjusted latitude from MODIS swath with dimension map

This data file contains data field Latitude and its type is 32-bit floating-point. The dumper just reads the lat data from that field and prints them on the screen.

If you want to print the adjusted (i.e., 4060x2708) latitude using swath dimension map, type the following command:

$eos2dump -a1mMYD02HKM.A2010031.0035.005.2010031183706.hdf
Figure 13. How to dump adjusted latitude of MODIS swath with dimension maps

The output of the above command is shown below:

-61.0802, -61.0949, -61.1096, -61.1241, -61.1387,
-61.1531, -61.1675, -61.1818,-61.196, -61.2102,
-61.2243, -61.2383, -61.2524, -61.2663, -61.2801,
-61.2939, -61.3077, -61.3213,-61.335, -61.3485,
-61.3621, -61.3755, -61.3889, -61.4022, -61.4155,
...
Figure 14. Result of dumping the adjusted latitude from MODIS swath with dimension map

In Figure 14., please note that the adjusted value -61.0949 is inserted between the first two data values (-61.0802, 61.1096) from Figure 12. It's calculated by the HDF-EOS2 Dumper internally. This will make latitude data have the exact same dimension size as the field data.

Example 4

The fourth example is to dump the longitude values of the Northern Hemisphere LAMAZ grid from the AMSR_E_L3_5DaySnow_V09_20050126.hdf HDF-EOS2 file. The file contains two grids in Lambert Azimuthal (GCTP_LAMAZ) projection for both Northern and Southern hemispheres.

$eos2dump -c2AMSR_E_L3_5DaySnow_V09_20050126.hdf "Northern Hemisphere"
Figure 15. How to dump longitude of AMSR_E grid

Please note that we did not use -m option and each line contains only one data. The -m option produces short lines at the ends of grid rows that are not modulo-5 values in length. For example, the last line may contain only 3 values at the end with -m option instead of 5.

This is acceptable for IDL, but MATLAB cannot handle the irregular length lines when the output is redirected to a text file and the text file is later parsed by MATLAB. Therefore, when you generate lat/lon dump output files in MATLAB, use only -a1, -a2, -c1, -c2 options. Do not use the -m option to produce geo-location coordinate files for use in MATLAB. Please see our MATLAB AMSR_E comprehensive examples to check how lat/lon files generated from eos2dump are used.

The output of the above command is shown below:

-135,
-135,
-135.16,
-135.24,
-135.32,
-135.401,
...
Figure 16. Result of dumping longitude of AMSR_E grid

Example 5

The last example is to dump the multiple dimension map information of the VNIR swath from the AST_L1B_00301032001190431_20110121213613_30524.hdf HDF-EOS2 file. The file contains multiple swaths with multiple dimension map pairs. For example, VNIR swath has two dimension map pairs. The first pair of lat/lon can be retrieved using -a1 and -a2 as explained above. The second pair of lat/lon should be retrieved using -a3 and -a4. The HDF-EOS2 dumper can support up to 4 pairs. That is, you can use -a5/-a6 for the third pair and -a7/-a8 for the fourth pair. The dumper doesn't support beyond the fourth pair because we haven't seen such case. You can examine if there are more dimension map pairs using -0 and -9 options.

$eos2dump -a4iAST_L1B_00301032001190431_20110121213613_30524.hdf "VNIR_Swath"
Figure 17. How to dump the second longitude of VNIR swath

The output of the above command is shown below:

DIMENSION ImageLine {{{
  size: 4200
}}}
DIMENSION ImagePixel {{{
  size: 4980
}}}
DIMENSION MAP GeoXtrack -> ImagePixel {{{
  offset: 0
  increment: 498
DIMENSION MAP GeoTrack -> ImageLine3B {{{
  offset: 400
  increment: 420
Figure 18. Result of dumping the second longitude information of VNIR Swath

You can compare the above output against the first longitude information of VNIR Swath that can be generated with -a2i option. The difference is highlighted in Figure 20.

DIMENSION ImageLine {{{
  size: 4200
}}}
DIMENSION ImagePixel {{{
  size: 4980
}}}
DIMENSION MAP GeoTrack -> ImageLine {{{
  offset: 0
  increment: 420
DIMENSION MAP GeoXtrack -> ImagePixel {{{
  offset: 0
  increment: 498
Figure 19. Result of dumping the first longitude information of VNIR Swath

Limitations

1. The program can't handle HDF-EOS2 file which contains 'DEFAULT' values for UpperLeft and LowerRight points. The example file is CER_ES4_TRMM-PFM_Edition1_009001.199808.hdf.

2. For LAMAZ projection, the 1.0.0 version produced erroneous lat and lon values ("1e+51") near the corners of the grid. This was due to a bug in the GCTP library. The newer (> 1.1.0) version checks for undefined values and returns the nearest-neighbor value within the valid range.

3. The program can't handle HDF-EOS2 file MISR_AM1_CGAS_MAR_01_2006_SITE_INTEXB_F06_0021.hdf. It has problem when calling "GDij2ll" function. The problem might come from the HDF-EOS2 library.

4. If the HDF-EOS2 file contains swath dimension map, using option -c will read unadjusted lat and lon that the date file provides. If you want to read adjusted lat and lon, option -a should be used instead. When the unadjusted lat and lon data contains fill value, the adjusted lat and lon will also contain fill value.

5. The number of output data per line could be chosen either 1 or 5 only for the use in other software, like MATLAB and IDL. There's no option to let users specify the number of data per line.

6. When the swath dimension maps are used, the adjusted lat and lon values may fall out of the valid range due to their closeness to the boundary lat/lon data provided in the data file. Here, we make those invalid values equal to the boundary points. Special cautions are needed when handling swath dimension map file.

See Also

Reference

[1] HDF-EOS Library User's Guide for EOSDIS Evolution and Development (EED) Contract, Volume 1: Overview and Examples https://git.earthdata.nasa.gov/rest/git-lfs/storage/DAS/hdfeos/cea0af2253a6802bd1f320e8ce7f840b34d46f355fd14ccf9a57596dd932dbf3?response-content-disposition=attachment%3B%20filename%3D%22HDF-EOS_UG.pdf%22%3B%20filename*%3Dutf-8%27%27HDF-EOS_UG.pdf


Last modified: 11/11/2020
About Us | Contact Info | Archive Info | Disclaimer
Sponsored by Subcontract number 4400528183 under Raytheon Contract number NNG15HZ39C, funded by NASA / Maintained by The HDF Group