[gdal-dev] python GetDescription() returns empty strings on 1.7.1
Frank Warmerdam
warmerdam at pobox.com
Mon Oct 11 10:33:51 EDT 2010
Matthieu Rigal wrote:
> Hi folks,
>
> Currently running GDAL 1.7.1, I noticed a regression towards the 1.6.x branch
> which I could not find in the tickets.
>
> Teh GetDescription() always seems to return empty strings, except for just
> created file and just setted description...
>
> Here is a description of the bug, I don't think it is quite the expected
> result :
>>>> from osgeo import gdal
>>>> xT = gdal.GetDriverByName('GTiff').Create('test-desc.tif',10,10,1)
>>>> xB = xT.GetRasterBand(1)
>>>> xB.SetDescription('test')
>>>> xT = None
>>>> xT2 = gdal.Open('test-desc.tif')
>>>> xT2.GetRasterBand(1).GetDescription()
> ''
>
> The 1.6.1 returns:
> 'test'
>
> Is it a known bug ? Solved in further versions ?
Matthieu,
I confirmed the problem but was unable to reproduce correction operation
against the current 1.6 branch so whatever changed appears to have changed
there as well.
I presume with 1.6.1 you are seeing a .aux.xml file created - is that right?
There is no special handling of the raster band description in the geotiff
driver itself, so saving it falls to the GDALPamRasterBand. I see it also
has no override for SetDescription() so it falls to GDALMajorObject to
hold the description. In GDALPamRasterBand::SerializeToXML() a non-empty
description will be saved to the .aux.xml file; however, SerializeToXML()
is not called unless there is some record of the PAM information being dirty.
Since SetDescription() was not overridded in GDALPamRasterBand there was
no mechanism to set GPF_DIRTY in the pam layer.
Without more investigation I can't see why things regressed after 1.6.1.
I suspect it was a case of other information being handled a different
way so less gets written to the .aux.xml file.
I believe the fix is to override SetDescription() in GDALPamRasterBand
and to set the dirty flag there.
I'd appreciate it if you could file a ticket, and copy in the above
discussion.
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 gdal-dev
mailing list