3

I am trying to use the GDAL Python script gdal2tiles.py to create a few sets of map tiles. Whenever I execute the script, it also creates a set of .png.aux.xml files for every regular map tile (.png). It does this for most zoom levels, but not all.

My problem is I would like to avoid generating these XML files entirely and I'm not sure how. I'm not sure why they're being created in the first place and I don't recall them being created before. Although I could delete all of them afterward, the datasets are rather large so I'd like to reduce the processing as much as possible.

It is my understanding that these are georeferenced images. I have tried looking online for anything about this issue but couldn't find what I needed. Does this relate to the difference between "Base Tiles" and "Overview Tiles"? Would specifying a EPSG help? Here is the command I used to tile. Perhaps one of my options is causing this to happen:

gdal2tiles.py --resampling=near --xyz --zoom=3-13 --srcnodata=0 --exclude --processes=4 --tilesize=256 dataset-raster.tif tile-output

Note that this seems to happen whether I'm tiling GeoTIFFs or VRTs. I am using GDAL version 3.3.2 on Linux Mint Xfce.

1
  • I do not really know why aux.xml files are generated but I get those as well with GDAL 3.4.1. I had some older tile directories remaining on my computer and there were no aux.xml files. I suggest to write mail to gdal-dev mailing list and ask. I think there is not any necessary information in the aux.xml files.
    – user30184
    Commented Apr 27, 2022 at 19:53

2 Answers 2

4

GDAL uses the .aux.xml files to store metadata, including statistics. You can disable completely by setting the environment variable GDAL_PAM_ENABLED=NO though I don't advise doing this permanently.

Linux:

export GDAL_PAM_ENABLED=NO
gdal2tiles.py --resampling=near --xyz --zoom=3-13 --srcnodata=0 --exclude --processes=4 --tilesize=256 dataset-raster.tif tile-output

Windows:

set GDAL_PAM_ENABLED=NO
gdal2tiles.py --resampling=near --xyz --zoom=3-13 --srcnodata=0 --exclude --processes=4 --tilesize=256 dataset-raster.tif tile-output

If temporarily disabling PAM support causes issues with gdal2tiles.py, you can leave it enabled, but tell GDAL to store the .aux.xml files in another directory by setting the environment variable GDAL_PAM_PROXY_DIR to a different folder

Linux:

export GDAL_PAM_PROXY_DIR=/tmp

Windows

set GDAL_PAM_PROXY_DIR=%TEMP%
1
  • 1
    PAM files that gdal2tiles create look pretty useless: <PAMDataset> <GeoTransform> 0.0000000000000000e+00, 1.0000000000000000e+00, 0.0000000000000000e+00, 0.0000000000000000e+00, 0.0000000000000000e+00, 1.0000000000000000e+00</GeoTransform> <Metadata domain="IMAGE_STRUCTURE"> <MDI key="INTERLEAVE">PIXEL</MDI> </Metadata> </PAMDataset> and disabling them should be safe.
    – user30184
    Commented Apr 27, 2022 at 21:02
1

Since this commit (2022-05-02) gdal2tiles does not write the .png.aux.xml files any more. Because the change is in the Python script there is no need to wait for the next GDAL release but users can just add the few new lines into existing gdal2tiles.py script.

gdal2tiles: do not generate .aux.xml files on overview tiles

6
  • Is this also true for gdal_retile?
    – Binx
    Commented Jun 17, 2022 at 17:24
  • Have yor tried?
    – user30184
    Commented Jun 18, 2022 at 0:12
  • Yes and it did produce .aux, ended up using os.envir['GDAL_PAM_PROXY_DIR']='NO'. Why would gdal_retile not be updated and gdal2tiles is? Is gdal2tiles meant to replace gdal_retile?
    – Binx
    Commented Jun 21, 2022 at 22:59
  • 1
    They are different tools. Gdal2tiles does not replace gdal_retile. I guess nobody has reported that gdal_retile has that behavior.
    – user30184
    Commented Jun 22, 2022 at 3:33
  • 1
    The newest of all is here github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/…. I think it does not have code to prevent creating the aux.xml files. Script in rather complicated and improvement may require more than just copy-paste.
    – user30184
    Commented Jun 22, 2022 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.