Opened 7 months ago

Closed 7 months ago

Last modified 7 months 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:
Cc:

Description

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.

Bad:

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.

Good:

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 Changed 7 months ago by Even Rouault

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 Changed 7 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 41577:

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

comment:3 Changed 7 months ago by Even Rouault

Milestone: 2.3.0

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

comment:4 Changed 7 months ago by Even Rouault

In 41674:

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

Note: See TracTickets for help on using tickets.