[Gdal-dev] Dataset instance has no attribute 'GetMetadataItem'

Frank Warmerdam warmerdam at pobox.com
Tue Jan 16 12:27:48 EST 2007

Martel, Christian wrote:
> Hi,
> With fwtools 1.1.3 on XP, I wrote this python script :
> import gdal
> gdal.AllRegister()
> dataset =
> gdal.Open('d:/geodata/digest/cib/cb05NJ1701_2/rpf/GJKJI22/00A56324.I22')
> fdt = dataset.GetMetadataItem("NITF_FDT")
> print fdt
> I get 
> AttributeError: Dataset instance has no attribute 'GetMetadataItem'
> I get the same answer with a tiff file.
> Plain GetMetadata() works great but I'd like to get specific item.
> I found no sample python script using GetMetadataItem. How should I call
> it ?


I see that neither the old nor the new python bindings have a getmetadataitem
operation.  You basically have to fetch all the metadata, and then check for
the individual item.


   md = dataset.GetMetadata()
   if md.has_key('NITF_FDT'):
     print md['NITF_FDT']

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