# Reading the Attributes of an HDF-EOS File

**URL:** <https://forum.hdfgroup.org/t/reading-the-attributes-of-an-hdf-eos-file/11902>\
**Category:** HDF4\
**Created:** [December 29, 2023, 10:51am UTC](https://forum.hdfgroup.org/t/reading-the-attributes-of-an-hdf-eos-file/11902 "2023-12-29T10:51:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ellisonccastro](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/e19adc/32.png) [@ellisonccastro](https://forum.hdfgroup.org/u/ellisonccastro)\
**Post date:** [December 29, 2023, 10:51am UTC](https://forum.hdfgroup.org/t/reading-the-attributes-of-an-hdf-eos-file/11902/1 "2023-12-29T10:51:37Z")

</div>

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](https://ccplot.org/pub/resources/HDF/HDF-EOS%20Library%20User%27s%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?

---

<div class="post-metadata">

**Author:** ![myang6](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@myang6](https://forum.hdfgroup.org/u/myang6)\
**Post date:** [January 9, 2024, 8:07pm UTC](https://forum.hdfgroup.org/t/reading-the-attributes-of-an-hdf-eos-file/11902/2 "2024-01-09T20:07:02Z")

</div>

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](https://portal.hdfgroup.org/documentation/index.html) to open this SDS and use the API like SDfindattr,SDattrinfo,SDreadattr to retrieve the attribute values.

Kent
