#5805 closed enhancement (fixed)
Add command-line ability to recalculate raster statistics
Reported by: | Mike Taves | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 2.0.0 |
Component: | Utilities | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | antonio |
Description
If a raster does not have statistics, gdalinfo -stats myfile.tif
can be used to calculate and add statistics. However, if values in the raster dataset are modified, further attempts to use gdalinfo -stats myfile.tif
do not force recalculation of statistics, since they already exist.
One strategy would be to allow gdalinfo
to force recalculation of statistics with either -stats
or -approx_stats
flags. (However, doesn't the the "info" part of this utility suggests that it is intended to not modify the file? Also, very minor and almost non-ticket-worthy: -approx_stats
is missing from usage string in gdalinfo.c)
A second and more intuitive strategy is to add this functionality to gdal_edit
. That is, add both -stats
and -approx_stats
flags to this utility, and call ComputeStatistics(approx_stats)
. Note that this utility has a related and conflicting -unsetstats
option (changeset:27608) which needs to be considered.
Attachments (1)
Change History (10)
comment:1 by , 9 years ago
Cc: | added |
---|
comment:2 by , 9 years ago
comment:4 by , 9 years ago
A correction to a previous comment is that gdalinfo -stats
does not modify the GeoTIFF file, but creates an .aux.xml file; see #5807. Unfortunately, the raster statistics do not appear to be updated by ComputeStatistics
if the .aux.xml file is present.
comment:6 by , 9 years ago
Milestone: | → 2.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:7 by , 9 years ago
trunk r28347 "Fix test_gdal_edit_py_5 when gdalnumeric is not available"
Hum I thought this was in a modified version of your patch. Weird.
comment:8 by , 9 years ago
Yes, it was modified, then lost somewhere in subsequent commit in git (where I did git push -f
, because I didn't understand other oddities). Thanks!
Also noteworthy, the
gdalinfo -mm
flag is documented as "Force computation of the actual min/max values for each band in the dataset" (viaGDALComputeRasterMinMax
). However, this option does not store the new partial statistics, it only displays the information in the output beside the previously computed and stored statistics. E.g., I modified a "2" pixel to a "3", thengdalinfo -mm
:In case it isn't clear, the intentions of this ticket are to calculate and store raster statistics.