[gdal-dev] get gdalinfo output with a python script

Eloi Ribeiro eloi.ribeiro at gmail.com
Wed Jun 9 07:33:46 EDT 2010


Thanks for the link Even!
There was everything I needed to know in line 338 - "Loop over bands".
I was missing this: Description = banda.GetDescription().

Thanks,
Eloi




On Tue, Jun 8, 2010 at 9:41 PM, Even Rouault
<even.rouault at mines-paris.org>wrote:

>
> http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/samples/gdalinfo.py
>
> Would need just a few minor changes to work against GDAL 1.7 python
> bindings
>
> Le Tuesday 08 June 2010 19:51:50 Eloi Ribeiro, vous avez écrit :
> > Hi,
> >
> > I don't manage to get all the info from a GRIB file with a python script
> as
> > it's possible with gdalinfo output.
> >
> > gdalinfo output example from a GRIB band:
> >
> > *Band 1 Block=720x1 Type=Float64, ColorInterp=Undefined*
> > *  Description = 2[m] HTGL="Specified height level above ground"*
> > *  Metadata:*
> > *    GRIB_UNIT=[K]*
> > *    GRIB_COMMENT=Minimum Temperature [K]*
> > *    GRIB_ELEMENT=TMIN*
> > *    GRIB_SHORT_NAME=2-HTGL*
> > *    GRIB_REF_TIME=   283996800 sec UTC*
> > *    GRIB_VALID_TIME=   284000400 sec UTC*
> > *    GRIB_FORECAST_SECONDS=0 sec*
> >
> > Till now I manage to get all Metadata tags but not all the info from the
> > tow first lines.
> > I am using the following code:
> >
> > *from osgeo import gdal*
> > *
> > *
> > *dataset = gdal.Open(filename, gdal.GA_ReadOnly)*
> > *if dataset is None:*
> > *    print 'Nao foi possivel abrir a imagem!'*
> > *for nBandas in range(1, dataset.RasterCount + 1):*
> > *    banda = dataset.GetRasterBand(nBandas)*
> > *    BlockSize = banda.GetBlockSize()*
> > *    DataType  = gdal.GetDataTypeName(banda.DataType)*
> > *    Metadata = banda.GetMetadata()*
> > *    for chave, valor in Metadata.iteritems():*
> > *        print chave, '=', valor.strip()*
> >
> > I would appreciate some help.
> > Thanks in advance.
>
>
>


-- 
Eloi Ribeiro
GIS Analyst
39,45º -4,40º
http://eloiribeiro.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100609/35088d7c/attachment.html


More information about the gdal-dev mailing list