How do I convert an HDF5/HDF-EOS5 file into binary format?
To convert HDF5 files into binary format you will need to use the h5dump utility, which is part of the HDF5 distribution available from the HDF Group. How you install HDF5 depends on your operating system. Full instructions for installing and using h5dump on Mac/Unix and Windows are provided below.
Installing HDF5 and using h5dump on Mac/Unix
Download ‘hdf5-1.12.0-Std-osx1013_64-intel.tar.gz’ from:
https://www.hdfgroup.org/downloads/hdf5/
If you haven’t already registered with the HDF Group, then you will need to create a free account to download the file.Move the downloaded file to where you would like to run the program from. Untar the file and this will produce the folder called ‘hdf’.
Open a terminal and navigate to the ‘hdf’ folder and run the ‘HDF5-1.12.0-Darwin.sh’ and follow the prompts.
Once installed, the h5dump can be found in the ‘HDF5-1.12.0-Darwin/HDF_Group/HDF/1.12.0/bin’ folder. Navigate to this folder and type the ‘pwd’ command to get the full directory of this folder. You can either you use this to run the command from wherever your HDF5 file is or you can add it to your $PATH in your .zshrc or .bash_profile file in your home directory.
In a terminal navigate to the folder where the HDF5/HDF-EOS5 file is that you want to convert. To dump the header information in the HDF5/HDF-EOS5 file into a text file you can use the following command:
h5dump --header <h5 filename> >> <output file>
For example, to output the header information from 'GLAH14_634_2131_002_0015_0_01_0001.H5' into a text file called ‘output.txt’:h5dump --header GLAH14_634_2131_002_0015_0_01_0001.H5 >> output.txt
The output text file will include the names of the attributes, groups and data sets in the file, so you can identify which variables you want to output in binary format.
To dump a data set from a HDF5/HDF-EOS5 file into a binary file you can use the following command:h5dump -d <variable location and name> -b LE -o <output binary file> <input HDF5 file>
To dump a group replace the '-d' with '-g' and for an attribute replace the '-d' with '-a'. You can dump multiple data sets, groups, and/or attributes into one binary file.
For example, to dump the group 'Geolocation' with the 'd_lat' and 'd_lon' variables and the data set 'd_elev' from the file 'GLAH14_634_2131_002_0015_0_01_001.H5' into a binary file 'GLAH14_converted.bin' in little endian format:h5dump -g /Data_40HZ/Geolocation -d /Data_40HZ/Elevation_Surfaces/d_elev -b LE -o GLAH14_converted.bin GLAH14_634_2131_002_0015_0_01_0001.H5
Installing HDF5 and using h5dump on Windows
Download the latest windows pre-built binary 'hdf5-1.12.0-Std-win10_64-vs14-Intel.zip' from the HDF Group:
https://www.hdfgroup.org/downloads/hdf5/
If you haven’t already registered with the HDF Group, then you will need to create a free account to download the file.Unzip the downloaded file. Then in the ‘hdf’ folder double click on the HDF5-1.12.0-win64 installer. This will start a wizard installer and follow the instructions for installation.
Once the installation is complete, to check that HDF5 has been added to your path, open a command prompt and type 'PATH'. The C:\Program Files\HDF_Group\HDF5\1.12.0\bin should be included in the list that appears.
In the command prompt navigate to the folder where the HDF5/HDF-EOS5 file you want to convert is.
To dump the header information in the HDF5/HDF-EOS5 file into a text file you can use the following command:
h5dump --header <h5 filename> >> <output file>
For example, to output the header information from 'GLAH14_634_2131_002_0015_0_01_0001.H5' into a text file called ‘output.txt’:h5dump --header GLAH14_634_2131_002_0015_0_01_0001.H5 >> output.txt
The output text file will include the names of the attributes, groups and data sets in the file, so you can identify which variables you want to output in binary format.
To dump a data set from a HDF5/HDF-EOS5 file into a binary file you can use the following command:
h5dump -d <variable location and name> -b LE -o <output binary file> <input HDF5 file>
To dump a group replace the '-d' with '-g' and for an attribute replace the '-d' with '-a'. You can dump multiple data sets, groups, and/or attributes into one binary file.
For example, to dump the group 'Geolocation' with the 'd_lat' and 'd_lon' variables and the data set 'd_elev' from the file 'GLAH14_634_2131_002_0015_0_01_001.H5' into a binary file 'GLAH14_converted.bin' in little endian format:h5dump -g /Data_40HZ/Geolocation -d /Data_40HZ/Elevation_Surfaces/d_elev -b LE -o GLAH14_converted.bin GLAH14_634_2131_002_0015_0_01_0001.H5