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

Dennis Gocke dengo at gmx.net
Thu Dec 27 14:24:49 PST 2018


Hi,

when you have a raster where stats and histogram have already been computed
and later on you edit some pixels programmatically (GDAL C API), previously
computed stats/histogram are not automatically invalidated/removed. For
performance reasons it probably makes sense, that this is not done
automatically and must be explicitly handled, but I'm not sure how to
correctly handle removing or updating stats and histogram.

I would actually prefer just to remove the stats and histogram, but if
that's not possible I can also recompute them.

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?

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?

Kind regards,
Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20181227/8f7e8886/attachment.html>


More information about the gdal-dev mailing list