[gdal-dev] Writing descriptions to GeoTiff bands

Andrew Bell andrew.bell.ia at gmail.com
Tue Sep 20 08:13:44 PDT 2016

On Sun, Sep 18, 2016 at 5:49 AM, Even Rouault <even.rouault at spatialys.com>

> Le dimanche 18 septembre 2016 11:02:20, Sean Gillies a écrit :
> > Hi Andrew, Even,
> >
> > I am so grateful you asked this question, Andrew.
> UPDATE: Andrew, after digging, I believe you have hit
> https://trac.osgeo.org/gdal/ticket/6592 whose fix hasn't yet reached any
> released version.

Thanks Even,

It seems like doing something else to set the metadata change flag will
make things work.  Unfortunately, the change flag seems to be guarded so
one has to make an actual change to get it to be set.  Something like the
following works, but is a little crufty and deserves a comment.  Perhaps
there's a better way?

int nBands = 5;
dataset->Create(filename, width, height, nBands, ...);

for (int i = 1; i <= nBands; ++i)
    GDALRasterBand *band = dataset->GetRasterBand(i);

    // Force metadata change flag so that description gets written.
Current bug
    // (ticket 6592) requires something like this.
    band->SetOffset(band->GetOffset(NULL) + .00001);
    band->SetOffset(band->GetOffset(NULL) - .00001);


Andrew Bell
andrew.bell.ia at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160920/f02126cb/attachment.html>

More information about the gdal-dev mailing list