[gdal-dev] removing/updating stats and histogram when editing raster

Even Rouault even.rouault at spatialys.com
Fri Dec 28 02:12:52 PST 2018


Dennis,

> Removing:
> If I'm not mistaken, stats can be removed by setting the
> "STATISTICS_MINIMUM", ... Metadata Items to null, or would that only work
> correctly for some raster formats?
> Is there a better way to remove previously computed statistics?
> How to remove the histogram?

In most cases, stats and histographs will be in a .aux.xml sidecar file that 
you may just delete (or edit to remove those elements). If they are internal 
to the raster format, that's more difficult and you may need to translate it.

> 
> Updating:
> Stats can be recomputed by calling GDALComputeRasterStatistics which will
> also update the corresponding metadata items.
> For the histogram calling GDALGetDefaultHistogramEx with bForce=1 will not
> recompute the histogram (it seems bForce is only relevant in cases where
> the histogram has not been computed before).
> What's the correct way to recompute the default histogram?

You may use
GDALGetRasterHistogramEx() + GDALSetDefaultHistogramEx()

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list