[gdal-dev] Need help in writing aux.xml (pam) using cpp

Christian Rapp crappbytes at gmail.com
Wed Jan 2 08:54:52 PST 2013


Am 02.01.2013 15:45, schrieb Even Rouault:
> 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

I see, thats a nice trick :) Thanks for the info!
>
> 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.
You mean I don't need GDALPamDataset/GDALPamRasterBandar at all? So no
need to cast the GDALDataset returned by GDALDriver::Create() to a
GDALPamDataset. Ok great, less work.

Great library, congratulations!

Regards
Christian Rapp
>


More information about the gdal-dev mailing list