#5463 closed defect (fixed)
gdal_translate with stats and a_nodata
Reported by: | Mike Taves | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.1 |
Component: | GDAL_Raster | Version: | 1.11.0 |
Severity: | normal | Keywords: | vrt statistics nodata |
Cc: |
Description
I have a gridded XYZ file that I'd like to translate to a GeoTIFF with NODATA and with statistics. Here an example source file myraster.xyz:
X Y Z 0 0 -999 1 0 10 0 1 15 1 1 20
So the command line is:
$ gdal_translate -a_nodata -999 -stats myraster.xyz myraster.tif
however from gdalinfo myraster.tif
Band 1 Block=2x2 Type=Int16, ColorInterp=Gray Min=-999.000 Max=20.000 Minimum=-999.000, Maximum=20.000, Mean=-238.500, StdDev=439.089 NoData Value=-999 Metadata: STATISTICS_MAXIMUM=20 STATISTICS_MEAN=-238.5 STATISTICS_MINIMUM=-999 STATISTICS_STDDEV=439.08911396207
How can the minimum value be the same as the NODATA? It's illogical.
It appears that -stats
was applied to myraster.xyz
which does not yet have a NODATA, since I see a new file myraster.xyz.aux.xml
with the same statistics without consideration of the NODATA.
One workaround is to set NODATA unintuitively in myraster.xyz.aux.xml
:
<PAMDataset> <PAMRasterBand band="1"> <NoDataValue>-9.99000000000000E+002</NoDataValue> </PAMRasterBand> </PAMDataset>
where the same translation results with expected results:
Band 1 Block=2x2 Type=Int16, ColorInterp=Gray Min=10.000 Max=20.000 Minimum=10.000, Maximum=20.000, Mean=15.000, StdDev=4.082 NoData Value=-999 Metadata: STATISTICS_MAXIMUM=20 STATISTICS_MEAN=15 STATISTICS_MINIMUM=10 STATISTICS_STDDEV=4.0824829046386
Change History (2)
comment:1 by , 10 years ago
Component: | default → GDAL_Raster |
---|---|
Keywords: | vrt statistics nodata added |
Milestone: | → 1.11.1 |
Resolution: | → fixed |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
trunk r27298, branches/1.11 r27299 "VRT: make sure nodata value set on VRT raster band is taken into account in statistics computation (#5463)"