Function Repository Resource:

LegacyHDFImport

Source Notebook

Import data from HDF (Hierarchical Data Format) files that utilize older versions of the HDF format

Contributed by: Arnoud Buzing

ResourceFunction["LegacyHDFImport"][file,"Datasets"]

returns the datasets from the given HDF file.

ResourceFunction["LegacyHDFImport"][file,"Attributes"]

returns the overall attributes from the given HDF file.

ResourceFunction["LegacyHDFImport"][file,{"Data",dataset}]

returns the named dataset from the given HDF file.

Details

LegacyHDFImport provides an interface for importing data from HDF files formatted with older versions of the HDF standard. This function allows users to extract datasets, data attributes, and specific data from these files seamlessly.
LegacyHDFImport should only be used on older HDF files (typically HDF version 4 and old) and only when Import with the "HDF" format fails.
LegacyHDFImport encapsulates functionality from the legacy pyhdf package.
LegacyHDFImport is designed to be used in environments where older versions of the HDF file format is prevalent, such as in scientific computing, remote sensing, and geospatial data analysis.
LegacyHDFImport works with CloudObject files by downloading them first to your Downloads folder.
LegacyHDFImport also works with File objects.

Examples

Basic Examples

Generate a legacy HDF version 4 file:

In[1]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/b050613f-5365-4908-979e-2310e45361ae"]
Out[1]=

Import the list of datasets:

In[2]:=
ResourceFunction["LegacyHDFImport"]["snow-cover.hdf", "Datasets"]
Out[2]=

Import the file attributes:

In[3]:=
ResourceFunction["LegacyHDFImport"]["snow-cover.hdf", "Attributes"]
Out[3]=

Import the data and visualize it:

In[4]:=
na = ResourceFunction["LegacyHDFImport"][
  "snow-cover.hdf", {"Data", "NDSI_Snow_Cover"}]
Out[4]=
In[5]:=
Image[na]
Out[5]=

Publisher

Arnoud Buzing

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 22 January 2025

License Information