[gdal-dev] Preventing .aux.xml output without disabling PAM

Pinner, Luke Luke.Pinner at environment.gov.au
Tue Mar 30 18:32:45 EDT 2010

Perhaps set the GDAL_PAM_PROXY_DIR environment var to some temp
directory and delete the directory after processing?


-----Original Message-----
From: gdal-dev-bounces at lists.osgeo.org
[mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Shaw,
Sent: Wednesday, 31 March 2010 7:59 AM
To: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] Preventing .aux.xml output without disabling PAM

I need to override the projection and geotransform for some of the
sources I process, but I want my changes effective in memory only. The
following code should do that (or so I thought), but it causes the file
S:\Maps\aux_test.bmp.aux.xml to be generated, even though I am trying to
prevent that by opening the file read only, setting the GPF_NOSAVE flag,
and even going so far as clearing the GPF_DIRTY flag after making a

I leave GDAL_PAM_ENABLED turned on because, in the same application, I
process other map sources which do supply .aux or .aux.xml files.

I am using FWTools 2.4.7 on Windows.

Any suggestions?

#include <iostream>
#include <ogr_srs_api.h> // for SRS_WKT_WGS84
#include <gdal.h>
#include <gdal_priv.h> // for GDALDataset
#include <gdal_pam.h> // for GDALPamDataset

int main(int argc, char **argv)

    GDALDataset *ds = (GDALDataset *)GDALOpenShared(
        "S:\\Maps\\test.bmp", GA_ReadOnly);

    GDALPamDataset *pamDs = dynamic_cast<GDALPamDataset *>(ds);
    if (pamDs != NULL)
        std::cout << "Initial flags: "
            << pamDs->GetPamFlags() << std::endl;

        int pamFlags = pamDs->GetPamFlags();
        pamFlags |= GPF_NOSAVE;

        std::cout << "GPF_NOSAVE set: "
            << pamDs->GetPamFlags() << std::endl;

    // causes a change to the PAM dataset that makes it "dirty"

    if (pamDs != NULL)
        std::cout << "After SetProjection(): "
            << pamDs->GetPamFlags() << std::endl;

        int pamFlags = pamDs->GetPamFlags();
        pamFlags &= ~GPF_DIRTY;

        std::cout << "GPF_DIRTY cleared: "
            << pamDs->GetPamFlags() << std::endl;
        // 16 is output; 16 is value of GPF_NOSAVE

    GDALClose(ds); // causes test.bmp.aux.xml to be written


Interestingly, the output is:

Initial flags: 0
GPF_NOSAVE set: 16
After SetProjection(): 16
GPF_DIRTY cleared: 16

I would have expected 0, 16 (nosave), 17 (dirty & nosave), 16.


gdal-dev mailing list
gdal-dev at lists.osgeo.org

If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments. 

Please consider the environment before printing this email.


More information about the gdal-dev mailing list