GDAL – How to Avoid Generating .png.aux.xml Files with gdal2tiles

gdalgdal2tilestiles

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.

Best Answer

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%