[GIS] How to create Raster statistics with GDAL externally

gdalgdalinfopythonstatistics

If I want to create a GDAL PAM statistics file with the command gdalinfo -stats from a GRIB file, e.g. needed for DynamicColorMapping, GDAL only creates the statistics internally inside the sourcefile. Is it possible to force gdalinfo -stats to create the additional file (.aux.xml)?

A way to do this is programmatically with Python and to tinker with the XML, but that doesn't fit my needs.

Best Answer

As a workaround you can use command

gdalinfo -stats -hist input.tif

Selecting the histogram option triggers the creation of input.tif.aux.xml file.

EDIT

I have learned that actually there is no need to use the -hist workaround. There is a GDAL configuration option GDAL_PAM_ENABLED that forces the creation of the .aux.xml file. Usage example:

gdalinfo test.tif -stats --config GDAL_PAM_ENABLED TRUE