Opened 6 years ago

Last modified 3 weeks ago

#4576 new defect

GDALRasterBand::ComputeStatistics() does not always call SetStatistics()

Reported by: bgp2000 Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:


The documentation says: "Once computed, the statistics will generally be 'set' back on the raster band using SetStatistics?().", yet if the block (bApproxOK && GetOverviewCount?() > 0 && HasArbitraryOverviews()) evaluates to true, that is not the case.

This might be a feature(not writing approximate data to the file) but it depends on how "generally" is interpreted. It seems rather arbitrary not to save the data in this case. At least the documentation could be clearer.

Change History (2)

comment:1 Changed 3 years ago by Jukka Rahkonen

I can find from the code of trunk/gdal/gcore/gdalrasterband.cpp only this in three places:

if ( bApproxOK && GetOverviewCount() > 0 && !HasArbitraryOverviews() )

I believe that there is a relation to issue #2108 "[PATCH] GDALRasterBand::ComputeStatistics?() does not use arbitrary overviews"

If I understand right the special handling in done for ECW and JPEG2000 which have arbitrary overviews. Because of #2108 the statistics for those is computed from a quickly subsampled image which has a size of about 2500 pixels only.

I think it is a feature to not to write statistics back to the file in this case. If it affects ECW, JPEG2000 and perhaps MrSID the behaviour is not so arbitrary but sure worth clearer documentation.

Note: See TracTickets for help on using tickets.