Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#7245 closed defect (fixed)

gdalwarp w/netCDF output forces nodata value of 0

Reported by: bnordgren Owned by: warmerdam
Priority: normal Milestone: 2.3.0
Component: default Version: unspecified
Severity: normal Keywords:


Using gdalwarp to resample an input image and store the result in a netCDF file results in the nodata value being set to zero for formats NC4 and NC4C. Formats NC and NC2 seem to work as expected. In my case, the target nodata value is 255 and the data type is byte.


gdalwarp -of netCDF -co FORMAT=NC4 ...
gdalwarp -of netCDF -co FORMAT=NC4C ... 

However, saving the results of the gdalwarp to geotiff format, then performing a separate gdal_translate to netCDF preserves the nodata value.


gdalwarp -of GTiff ... 
gdal_translate -of netCDF -co FORMAT=NC4 ...

Attempting to set the nodata value with -dstnodata 255 results in:

ERROR 1: netcdf error #-122 : NetCDF: Attempt to define fill value when data already exists. .

Change History (4)

comment:1 by Even Rouault, 5 years ago

In 41576:

gdalwarp: make sure to try to redefine the destination nodata value from the source nodata even if the newly created dataset has already set a default nodata value (refs #7245)

comment:2 by Even Rouault, 5 years ago

Resolution: fixed
Status: newclosed

In 41577:

netCDF: fix bad interaction of SetNoDataValue() and SetGeoTransform()/SetProjection() for NC4/NC4C modes (fixes #7245)

comment:3 by Even Rouault, 5 years ago

Milestone: 2.3.0

I didn't quite reproduce your exact errors, but I did see issues fixed by above commits.

comment:4 by Even Rouault, 5 years ago

In 41674:

netCDF: fix memory leak introduced in r41577 (trunk only, refs #7245)

Note: See TracTickets for help on using tickets.