I am trying to extract a subdataset from HDF raster. Later on, I intend to make operations such as mosaicking and extracting raster averages from the extracted subdataset. The following code is supposed to extract the subdataset, but it seems to me that all it does is extracting the subdataset NAME and not the object itself:
import gdal
from gdalconst import *
filename= "Image.hdf"
dataset = gdal.Open(filename,GA_ReadOnly)
subdataset = dataset.GetSubDatasets()[1]
print(type(dataset))
print(type(subdataset))
Now, if you run this, the type of the dataset and subdataset objects will be printed out:
<class 'osgeo.gdal.Dataset'>
<type 'tuple'>
So, the extracted subdataset is just a tuple. How can I use it to do mosaicking? Am I missing something here? P.S. HDF rasters can be easily downloaded from this FTP site: ftp://ladsweb.nascom.nasa.gov/allData/5/MOD11A1/2012/193/