<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Even,<div><br></div><div>Thanks for the quick reply.</div><div><br></div><div>Regarding removing stats: I just noticed that the gdal_edit.py script also just removes all metadata items starting with the 'STATISTICS_'. So that's probably the way to go.</div><div><br></div><div>For removing the histogram there is no such option in gdal_edit.py</div><div><br></div><div>Your suggestion with GDALGetRasterHistogramEx() + GDALSetDefaultHistogramEx() will not work for updating the histogram.</div><div>GDALGetRasterHistogramEx will not recompute the histogram, but instead will fetch the existing histogram if the settings (min,max,bincount) match.<br></div><div>In cases the settings don't match (e.g. different max) it will compute a new histogram and add it to the aux.xml, but the old invalid histogram will still be there.</div><div>When GDALSetDefaultHistogramEx is called the invalid histogram will still not be removed, but instead just the order of the histograms will be changed.</div><div><br></div><div>So it seems separately (not using GDAL) removing/editing the aux.xml file is currently the only option.</div><div>In my opinion that is a bit odd.</div><div>I think it would be good to have methods to remove statistics and histograms. </div><div>Having those methods would also highlight that these methods need to be explicitly called when the raster is edited and that they are not automatically invalidated.</div><div><br></div><div>Another small question: Is there a GDAL config option, to make GDAL save computed statistics to the aux.xml file instead of the raster file itself when the raster is opened in EditMode?</div><div><br></div><div>Kind regards,</div><div>Dennis</div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">Am Fr., 28. Dez. 2018 um 04:12 Uhr schrieb Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dennis,<br>
<br>
> Removing:<br>
> If I'm not mistaken, stats can be removed by setting the<br>
> "STATISTICS_MINIMUM", ... Metadata Items to null, or would that only work<br>
> correctly for some raster formats?<br>
> Is there a better way to remove previously computed statistics?<br>
> How to remove the histogram?<br>
<br>
In most cases, stats and histographs will be in a .aux.xml sidecar file that <br>
you may just delete (or edit to remove those elements). If they are internal <br>
to the raster format, that's more difficult and you may need to translate it.<br>
<br>
> <br>
> Updating:<br>
> Stats can be recomputed by calling GDALComputeRasterStatistics which will<br>
> also update the corresponding metadata items.<br>
> For the histogram calling GDALGetDefaultHistogramEx with bForce=1 will not<br>
> recompute the histogram (it seems bForce is only relevant in cases where<br>
> the histogram has not been computed before).<br>
> What's the correct way to recompute the default histogram?<br>
<br>
You may use<br>
GDALGetRasterHistogramEx() + GDALSetDefaultHistogramEx()<br>
<br>
Even<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
</blockquote></div>