[FWTools] How to access the HDF files' attribute information in c#

Frank Warmerdam warmerdam at pobox.com
Mon Jun 29 21:17:40 EST 2009


jor sion wrote:
> Hi, 
>  
> I would write a program via FwTools in c# to read HDF files. Part of the 
> file structure shows in the picture bellow:
>  
> hdf.png
>  
> For example, as  the picture shows, how to get the information about 
> "Number of Night mode scans" (the value about the selected Node).
>  
> I don't know how to access the information about such format nodes (all 
> saved in text formats) in hdf files.
> 
> Any one could help me? Thanks.

JoSn,

The GDAL HDF driver does not expose all the metadata available in the
HDF file.  If you need full access you will need something more direct.

However, quite a bit of metadata is available.  When I run gdalinfo on
an old MODIS swath I have around I get lots of stuff like:


Metadata:
   Miami Format=10
   Number of bands=6
   Number of samples per record=1354
   Number of records=2030
   Common L2 Flag Usage=LAND1
...
   CorVer=vis from 2000306.1630; ir from 2000306.1720 0050 2305
   MsKeyWords= binside=0
   LOCALGRANULEID=MOD28L2.A2001213.1525.004.2002197060500.hdf
   PRODUCTIONDATETIME=2002-07-16T06:05:00.000Z
   DAYNIGHTFLAG=Day
   REPROCESSINGACTUAL=processed once
   LOCALVERSIONID=1
   REPROCESSINGPLANNED=further update is anticipated
   SCIENCEQUALITYFLAG=Not Investigated
   AUTOMATICQUALITYFLAGEXPLANATION=look at the quality values of the individual 
pixels
   AUTOMATICQUALITYFLAG=Passed
   SCIENCEQUALITYFLAGEXPLANATION=See 
http://modis-ocean.gsfc.nasa.gov/qa/knownprobs.html for more details on MODIS 
Ocean data quality.
   QAPERCENTMISSINGDATA=100
   QAPERCENTOUTOFBOUNDSDATA=0
   QAPERCENTCLOUDCOVER=0
   QAPERCENTINTERPOLATEDDATA=0
   PARAMETERNAME=sst
...

I would suggest you do something similar to see what is available.

In C# you can use the GetMetadata() method to fetch the metadata
from the Dataset object.  I'm not positive about the exact syntax.

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    | Geospatial Programmer for Rent



More information about the FWTools mailing list