Reading the Attributes of an HDF-EOS File

I am reading an HDF-EOS swath file with HDFEOS2 built with HDF4, and I want to read the attributes of a data field such as the valid range, fill value, and scale factor. The file has this structure:

  • Swath
    • Data Field (e.g. Radiance)
      • Valid Range
      • Fill Value
      • Scale Factor

I can read the data fields just fine, that is the radiance data in the example, using swattach and swrdfld. But I do not know how to proceed from there. I have also been reading this reference guide (https://ccplot.org/pub/resources/HDF/HDF-EOS%20Library%20User’s%20Guide,%20Volume%202:%20Function%20Reference%20Guide.pdf) but there doesn’t seem to be a direct function of retrieving the attributes. Although I can hard-code these values into my code, I want to give my code some flexibility in the event that the attributes change due updates/changes in the HDF-EOS file.

Is there a way to retrieve these information?

There are no HDF-EOS2 APIs to retrieve these attributes. I believe that these attributes are added by using HDF4 APIs directly. So if you want to retrieve the values of these attributes, you have to use the HDF4 APIs to do the job. In your example, Radiance is mostly an SDS. So you should follow the HDF4 documents under Documentation | The HDF Group to open this SDS and use the API like SDfindattr,SDattrinfo,SDreadattr to retrieve the attribute values.

Kent