07 November 2022 1 2K Report

I am trying to read a MODIS HDF file with Python. I have used GDAL and pyhdf libraries. However, I am unsure why GDAL is unable to read location coordinates whereas pyhdf can read the same easily.

Following is the simple python code.

```

from pyhdf import SD

from osgeo import gdal

filename = 'MYD04_3K.A2016001.0310.061.2018059005952.hdf'

gdal_ds= gdal.Open(filename)

hdf_ds = SD.SD(filename)

print (hdf_ds.datasets())

for path, desc in file.GetSubDatasets():

print(desc)

```

The output for pyhdf is as follows:

{'Longitude': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'), (676, 451), 5, 0), 'Latitude': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'), (676, 451), 5, 1), 'Scan_Start_Time': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'), (676, 451), 6, 2), 'Solar_Zenith': (('Cell_Along_Swath:mod04', 'Cell_Across_Swath:mod04'),

The output for GDALis as follows:

[676x451] Scan_Start_Time mod04 (64-bit floating-point)

[676x451] Solar_Zenith mod04 (16-bit integer)

[676x451] Solar_Azimuth mod04 (16-bit integer)

I would like to learn why GDAL is unable to read location coordinates here. Is there anything I'm missing? How can I extract the location information by using GDAL library? My main aim eventually is to plot a specific variable from HDF file on map.

More Puneet Verma's questions See All
Similar questions and discussions