<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.m3353907767255063514qt-msonormal, li.m3353907767255063514qt-msonormal, div.m3353907767255063514qt-msonormal
        {mso-style-name:m_3353907767255063514qt-msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.Shkpostityyli19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">Third approach, convert the image into VRT format into a temporary directory and both the SRS and statistics will go into the VRT file:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">gdal_translate -of VRT -stats input.tif \temp_dir\for_metadata.vrt.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">I guess that the temp_dir can be in memory if it feels good.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> gda-dev <gdal-dev-bounces@lists.osgeo.org>
<b>Puolesta </b>Sean Gillies<br>
<b>Lähetetty:</b> maanantai 10. lokakuuta 2022 16.43<br>
<b>Vastaanottaja:</b> Laurențiu Nicola <lnicola@dend.ro><br>
<b>Kopio:</b> gdal dev <gdal-dev@lists.osgeo.org><br>
<b>Aihe:</b> Re: [gdal-dev] Computing statistics from raster dataset without writing aux.xml<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, Oct 10, 2022, 6:51 AM Laurențiu Nicola via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Hi Mats,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">This won't help you, but I wanted to suggest you make a temporary directory, copy the .aux.xml file there, then set
</span><span style="font-family:"Menlo",serif">GDAL_PAM_PROXY_DIR</span><span style="font-family:"Arial",sans-serif">. Unfortunately, at least in my test, GDAL still seems to save the file next to the input, even when calling
</span><span style="font-family:"Menlo",serif">SetConfigOption</span><span style="font-family:"Arial",sans-serif"> before doing anything else.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Regards,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Laurentiu<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal">On Mon, Oct 10, 2022, at 13:11, Budalen, Mats Bruun via gdal-dev wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt" id="m_3353907767255063514qt">
<div>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB">Hello!</span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB">I’m writing a Python program which reads raster data. The program uses the
<b>ComputeStatistics()</b> 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
<b>gdal.SetConfigOption('GDAL_PAM_ENABLED','NO')</b> before I open the dataset.</span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB">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.</span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB">Is there any way to compute statistics without creating/changing the aux.xml, while at the same time reading the SRS?</span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB">Regards,</span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="m3353907767255063514qt-msonormal"><span lang="EN-GB">Mats Budalen</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">_______________________________________________<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">gdal-dev mailing list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="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" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>