[gdal-dev] HDF subdatasets

Bobby Braswell rob.braswell at unh.edu
Wed Jan 23 14:32:52 EST 2008


Thanks very much.

Sorry, I saw that documentation but didn't make the connection about  
how to access the various domains.

Regards,
Rob

On Jan 23, 2008, at 2:15 PM, Frank Warmerdam wrote:

> Bobby Braswell wrote:
>> Hi-
>> Is it possible to access the names of subdatasets in HDF4 files  
>> using gdal-python? I can get the SDS names using gdalinfo, but  
>> would like to do it from within my code.
>> For example the result of
>> D = gdal.Open('MCD43A4.A2002001.h18v01.005.2007115060137.hdf')
>> produces some dictionaries within D containing metadata  
>> information, but I can't find the subdataset names anywhere, e.g.,
>> 'HDF4_EOS:EOS_GRID:"MCD43A4.A2002001.h18v01.005.2007115060137.hdf":Na 
>> dir_Reflectance_Band1'
>
>
> Bobby,
>
> You should be able to fetch the subdataset metadata using:
>
>  sdlist = D.GetMetadata( 'SUBDATASETS' )
>
> eg.
>
> >>> import gdal
> >>> D = gdal.Open('NISE_SSMIF11_19911227.HDFEOS')
> GDAL: GDALOpen(NISE_SSMIF11_19911227.HDFEOS) succeeds as HDF4.
> >>> print D.GetMetadata('SUBDATASETS')
> {'SUBDATASET_2_NAME':  
> 'HDF4_EOS:EOS_GRID:"NISE_SSMIF11_19911227.HDFEOS":Northern  
> Hemisphere:Age', 'SUBDATASET_4_DESC': '[721x721] Age Southern  
> Hemisphere (8-bit unsigned integer)', 'SUBDATASET_4_NAME':  
> 'HDF4_EOS:EOS_GRID:"NISE_SSMIF11_19911227.HDFEOS":Southern  
> Hemisphere:Age', 'SUBDATASET_3_NAME':  
> 'HDF4_EOS:EOS_GRID:"NISE_SSMIF11_19911227.HDFEOS":Southern  
> Hemisphere:Extent', 'SUBDATASET_2_DESC': '[721x721] Age Northern  
> Hemisphere (8-bit unsigned integer)', 'SUBDATASET_1_DESC':  
> '[721x721] Extent Northern Hemisphere (8-bit unsigned integer)',  
> 'SUBDATASET_3_DESC': '[721x721] Extent Southern Hemisphere (8-bit  
> unsigned integer)', 'SUBDATASET_1_NAME':  
> 'HDF4_EOS:EOS_GRID:"NISE_SSMIF11_19911227.HDFEOS":Northern  
> Hemisphere:Extent'}
>
> Note, the return value is a dictionary with keys of the form
> SUBDATASET_n_NAME and SUBDATASET_n_DESC.
>
> You might also want to skim the portion of
>
>   http://www.gdal.org/gdal_datamodel.html
>
> with the subtitle "SUBDATASETS Domain".
>
> Best regards,
> -- 
> --------------------------------------- 
> +--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,  
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President OSGeo, http:// 
> osgeo.org



More information about the gdal-dev mailing list