Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#5084 closed defect (fixed)

duplicate nodata metadata in netcdf files copied with gdal_translate

Reported by: etourigny Owned by: etourigny
Priority: normal Milestone: 1.10.1
Component: default Version: unspecified
Severity: normal Keywords: netcdf, nodata
Cc:

Description

when a netcdf file has nodata field defined in missing_value metadata and is copied using gdal_translate(or CreateCopy?()), a new nodata value is added in _FillValue metadata.

If the new nodata value is different this can lead to conflicting nodata values, depending on softawre used.

example using trmm.nc in autotest (extra output deleted):

$ ncatted -O -a missing_value,pcp,a,f,0 trmm.nc trmm-miss.nc
$ ncatted -a _FillValue,pcp,d,, trmm-miss.nc
$ gdal_translate -a_nodata -1 -of netcdf trmm-miss.nc  trmm-miss2.nc
Input file size is 40, 40
0...10...20...30...40...50...60...70...80...90...100 - done.
$ ncdump -h trmm-miss2.nc
netcdf trmm-miss2 {
dimensions:
	lon = 40 ;
	lat = 40 ;
	time = 1 ;
variables:
...
	float pcp(time, lat, lon) ;
		pcp:long_name = "precipitation:Precipitation" ;
		pcp:_FillValue = -1.f ;
		pcp:comments = "Unknown1 variable comment" ;
		pcp:grid_name = "grid-1" ;
		pcp:level_description = "Earth surface" ;
		pcp:missing_value = 0 ;
		pcp:time_statistic = "instantaneous" ;
}
$ gdalinfo trmm-miss2.nc
Driver: netCDF/Network Common Data Format
Files: trmm-miss2.nc
...
Band 1 Block=40x1 Type=Float32, ColorInterp=Undefined
  NoData Value=-1
  Metadata:
    _FillValue=-1
    missing_value=0

solution is to strip _FillValue and missing_value from metadata when copying, and let driver assign proper metadata (_FillValue)

Change History (2)

comment:1 Changed 5 years ago by etourigny

Resolution: fixed
Status: newclosed

fixed in trunk (r26005)

comment:2 Changed 5 years ago by etourigny

fixed in 1.10 (r26008)

Note: See TracTickets for help on using tickets.