[gdal-dev] Need help in writing aux.xml (pam) using cpp
Even Rouault
even.rouault at mines-paris.org
Wed Jan 2 06:45:09 PST 2013
Selon Christian Rapp <crappbytes at gmail.com>:
> Hello altogether and happy new year,
>
>
> I just started using the GDAL c++ interface. I want to create float32
> based GEoTiffs. This works quite well but in ArcMap they don't look that
> good because Statistics are missing.
>
> So first of all I called GetStatistics() Method from a Standard
> GDALDataset. This had no effect, at least ArcMap stilled complained
> about missing statistics. Then I switched to GDALPamDataset and
> GDALPamRasterBand and tried the same method again. Using the exiftool
> from Phil Harvey I see the statistics were written in the GDALMetadata
> section Even Esri recognizes this. Ok even better but why don't I get
> this values in an external aux.xml file?
> Right now I just call GetStatistics() right before GDALClose().
>
> I also had a look at code of the gdalinfo tool. Because gdalinfo -stat
> creates what I want. But I don't see anything what could help me.
If you want the statistics in a external .aux.xml file, open the dataset in
GA_ReadOnly mode, call GetStatistics() and GDALClose() it. That's what gdalinfo
does
Ah, and no need to cast to GDALPamDataset/GDALPamRasterBand: just use
GetStatistics() on the band object returned by GetRasterBand(), as
GetStatistics() is a virtual method of GDALRasterBand(). And the GTiff driver
extends GDALPamRasterBand, so the GetStatistics() implementation used will be
the one of GDALPamRasterBand.
More information about the gdal-dev
mailing list