<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Andrea, I'm new to this but the following works for me:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier">from osgeo import gdal</font></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier">hdf = gdal.Open('MCD43A4.A2002001.h12v04.005.2007114135144.hdf')</font></div><div><font class="Apple-style-span" face="Courier">sdsdict = hdf.GetMetadata('SUBDATASETS')</font></div><div><font class="Apple-style-span" face="Courier">sdslist =[sdsdict[k] for k in sdsdict.keys() if '_NAME' in k]</font></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier">names=[]</font></div><div><font class="Apple-style-span" face="Courier">for l in sdslist:</font></div><div><font class="Apple-style-span" face="Courier"> names.append(l)</font></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier">hdf = None</font></div><div><font class="Apple-style-span" face="Courier"><br class="webkit-block-placeholder"></font></div><div><font class="Apple-style-span" face="Courier">sds=[]</font></div><div><font class="Apple-style-span" face="Courier">for n in names:</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Courier">        </font></span><font class="Apple-style-span" face="Courier">sds.append(gdal.Open(n))</font></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>At this point I can inspect the metadata for the subdatasets, e.g.,</div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" face="Courier">sds[0].GetMetadata()</font></div><div><font class="Apple-style-span" face="Courier">sds[0].RasterCount</font></div><div><br class="webkit-block-placeholder"></div><div>Or retreive the image data in the layer corresponding to that subdataset, e.g.,</div><div><br class="webkit-block-placeholder"></div><div><font class="Apple-style-span" face="Courier">layer = sds[0].ReadAsArray()</font></div><div><font class="Apple-style-span" face="Courier">type(layer)</font></div><div><font class="Apple-style-span" face="Courier">dir(layer)</font></div><div><font class="Apple-style-span" face="Courier">layer.shape</font></div><div><br class="webkit-block-placeholder"></div><div><br></div><div>Good luck,</div><div>Rob Braswell</div><div><br></div></div><br><div><div>On Jan 25, 2008, at 6:44 AM, <a href="mailto:andrea.pistoni@next.it">andrea.pistoni@next.it</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Rob!<br><br>Maybe you can help me. I'm using Gdal.Open() method to open an HDF5 file with attributes and Dataset inside.<br>I work with C#. The "Open" method opens the file but I cannot see the Raster contained in it and the RasterCount property is 0 (seem such as it don't see the raster). <br>Is there a command of GDAL to acces directly to a specific Dataset inside a HDF5 file?<br>Using GetMetadata("SUBDATASET") I get the list of Dataset with name, path and dimensions but How can I get the Dataset Matrix? The "ReadRaster" method doesn't work because the Dataset ds has RasterCount equals to zero<br>An example of my code is:<br>....<br>Dataset ds = Gdal.Open("c:\Test.h5", "c:\plotina.bmp");<br>....<br><br>Thank in advance<br><br>Andrea<br><br>-------------------------------------<br><br><br>Bobby Braswell wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Hi-<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Is it possible to access the names of subdatasets in HDF4 files using <br></blockquote><blockquote type="cite">gdal-python? I can get the SDS names using gdalinfo, but would like <br></blockquote><blockquote type="cite">to do it from within my code.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">For example the result of<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">D = gdal.Open('MCD43A4.A2002001.h18v01.005.2007115060137.hdf')<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">produces some dictionaries within D containing metadata information, <br></blockquote><blockquote type="cite">but I can't find the subdataset names anywhere, e.g.,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">'HDF4_EOS:EOS_GRID:"MCD43A4.A2002001.h18v01.005.2007115060137.hdf":Nadir <br></blockquote><blockquote type="cite">_Reflectance_Band1'<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks very much,<br></blockquote><blockquote type="cite">Rob Braswell<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">gdal-dev mailing list<br></blockquote><blockquote type="cite"><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br></blockquote><blockquote type="cite"><a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote>Quoted from: <a href="http://www.nabble.com/HDF-subdatasets-tp15049650p15049650.html">http://www.nabble.com/HDF-subdatasets-tp15049650p15049650.html</a><br></blockquote></div><br></body></html>