[gdal-dev] Computing statistics from raster dataset without writing aux.xml

Rahkonen Jukka jukka.rahkonen at maanmittauslaitos.fi
Mon Oct 10 07:21:48 PDT 2022


Hi,

Third approach, convert the image into VRT format into a temporary directory and both the SRS and statistics will go into the VRT file:

gdal_translate -of VRT -stats input.tif \temp_dir\for_metadata.vrt.

I guess that the temp_dir can be in memory if it feels good.

-Jukka Rahkonen-

Lähettäjä: gda-dev <gdal-dev-bounces at lists.osgeo.org> Puolesta Sean Gillies
Lähetetty: maanantai 10. lokakuuta 2022 16.43
Vastaanottaja: Laurențiu Nicola <lnicola at dend.ro>
Kopio: gdal dev <gdal-dev at lists.osgeo.org>
Aihe: Re: [gdal-dev] Computing statistics from raster dataset without writing aux.xml

Hi,

Another approach, also involving a copy, is to read the raster data as numpy arrays and compute the statistics of those arrays. The GDAL method also has to read the raster data to compute statistics, of course, but doesn't store the entirety of it in memory.


On Mon, Oct 10, 2022, 6:51 AM Laurențiu Nicola via gdal-dev <gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>> wrote:
Hi Mats,

This won't help you, but I wanted to suggest you make a temporary directory, copy the .aux.xml file there, then set GDAL_PAM_PROXY_DIR. Unfortunately, at least in my test, GDAL still seems to save the file next to the input, even when calling SetConfigOption before doing anything else.

Regards,
Laurentiu

On Mon, Oct 10, 2022, at 13:11, Budalen, Mats Bruun via gdal-dev wrote:

Hello!



I’m writing a Python program which reads raster data. The program uses the ComputeStatistics() function on the dataset, which automatically attempts to write the result to an .aux.xml next to the raster file. I do not under any circumstance want to try to write to the source directory, so I have set gdal.SetConfigOption('GDAL_PAM_ENABLED','NO') before I open the dataset.



My program will sometimes come across datasets where the SRS is only defined in an aux.xml. Unfortunately, the above ConfigOption prevents the SRS definition from being read from the aux.xml.



Is there any way to compute statistics without creating/changing the aux.xml, while at the same time reading the SRS?





Regards,



Mats Budalen
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/gdal-dev<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgdal-dev&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Cb38698249e6b4faf2c2a08daaac5641c%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638010062006811240%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=VL9i%2FSjvCD%2B14VvxM37TXCLzniuGIkA%2BGrSAAtdhKZY%3D&reserved=0>


_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org<mailto:gdal-dev at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/gdal-dev<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgdal-dev&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Cb38698249e6b4faf2c2a08daaac5641c%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C1%7C638010062006811240%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=VL9i%2FSjvCD%2B14VvxM37TXCLzniuGIkA%2BGrSAAtdhKZY%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20221010/00beab36/attachment-0001.htm>


More information about the gdal-dev mailing list