Discussion:
[gdal-dev] Resampling causes change of max value
Denis Rykov
2021-05-20 19:42:59 UTC
Permalink
$ gdalinfo -stats -json input_raster_to_resize_with_max_val_92.tiff |
jq '.bands[0].metadata[""].STATISTICS_MAXIMUM'
"92"
$ gdal_translate -outsize 1% 1%
input_raster_to_resize_with_max_val_92.tiff output.tif
Input file size is 6845, 10302
0...10...20...30...40...50...60...70...80...90...100 - done.
$ gdalinfo -stats -json output.tif | jq
'.bands[0].metadata[""].STATISTICS_MAXIMUM'
"3149.9255371094"
I expected to get the same or at least close value as in the original
raster. What might be the reason for that behavior?
Even Rouault
2021-05-20 19:51:57 UTC
Permalink
Denis,

The maximum of nearest downsampling should be <= maximum of full resolution.

Potential explanations:

- your source file has overviews that contain completely different
values than the full resolution image.

- or perhaps your input_raster_to_resize_with_max_val_92.tiff file has a
.aux.xml with outdated stats (gdalinfo -stats doesn't regenerate stats
if already found)

Even
|$ gdalinfo -stats -json input_raster_to_resize_with_max_val_92.tiff |
jq '.bands[0].metadata[""].STATISTICS_MAXIMUM' "92" $ gdal_translate
-outsize 1% 1% input_raster_to_resize_with_max_val_92.tiff output.tif
Input file size is 6845, 10302
0...10...20...30...40...50...60...70...80...90...100 - done. $
gdalinfo -stats -json output.tif | jq
'.bands[0].metadata[""].STATISTICS_MAXIMUM' "3149.9255371094" |I expected to get the same or at least close value as in the original
raster. What might be the reason for that behavior?||
|
|
_______________________________________________
gdal-dev mailing list
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
http://www.spatialys.com
My software is free, but my time generally not.
Denis Rykov
2021-05-20 20:13:04 UTC
Permalink
Thank you Even. You are totally right as always. The reason is the broken
overview.

$ gdal_translate -outsize 1% 1% -oo OVERVIEW_LEVEL=0
input_raster_to_resize_with_max_val_92.tiff output-0ovr.tif

$ gdal_translate -outsize 1% 1% input_raster_to_resize_with_max_val_92.tiff
output.tif

$ gdalinfo -stats -json output.tif | jq
'.bands[0].metadata[""].STATISTICS_MAXIMUM'
"3149.9255371094"

$ gdalinfo -stats -json output-0ovr.tif | jq
'.bands[0].metadata[""].STATISTICS_MAXIMUM'
"70.651634216309"
Post by Even Rouault
Denis,
The maximum of nearest downsampling should be <= maximum of full resolution.
- your source file has overviews that contain completely different values
than the full resolution image.
- or perhaps your input_raster_to_resize_with_max_val_92.tiff file has a
.aux.xml with outdated stats (gdalinfo -stats doesn't regenerate stats if
already found)
Even
$ gdalinfo -stats -json input_raster_to_resize_with_max_val_92.tiff | jq '.bands[0].metadata[""].STATISTICS_MAXIMUM'
"92"
$ gdal_translate -outsize 1% 1% input_raster_to_resize_with_max_val_92.tiff output.tif
Input file size is 6845, 10302
0...10...20...30...40...50...60...70...80...90...100 - done.
$ gdalinfo -stats -json output.tif | jq '.bands[0].metadata[""].STATISTICS_MAXIMUM'
"3149.9255371094"I expected to get the same or at least close value as in the original raster. What might be the reason for that behavior?
_______________________________________________
-- http://www.spatialys.com
My software is free, but my time generally not.
Loading...