Opened 4 years ago

Closed 4 years ago

Last modified 4 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


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 in autotest (extra output deleted):

$ ncatted -O -a missing_value,pcp,a,f,0
$ ncatted -a _FillValue,pcp,d,,
$ gdal_translate -a_nodata -1 -of netcdf
Input file size is 40, 40
0...10...20...30...40...50...60...70...80...90...100 - done.
$ ncdump -h
netcdf trmm-miss2 {
	lon = 40 ;
	lat = 40 ;
	time = 1 ;
	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
Driver: netCDF/Network Common Data Format
Band 1 Block=40x1 Type=Float32, ColorInterp=Undefined
  NoData Value=-1

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 4 years ago by etourigny

Resolution: fixed
Status: newclosed

fixed in trunk (r26005)

comment:2 Changed 4 years ago by etourigny

fixed in 1.10 (r26008)

Note: See TracTickets for help on using tickets.