Ticket #4484 (assigned defect)
gdalwarp on large netcdf datasets sets data from first input dataset to <nodata> and generates error if -dstnodata option is used with netcdf-4 file
| Reported by: | hsumanto | Owned by: | etourigny |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | default | Version: | unspecified |
| Severity: | normal | Keywords: | netcdf |
| Cc: | etourigny |
Description
Was trying to combine 2 large netcdf tiles into a single tile using gdalwarp and found a few interesting issues below:
The two large netcdf tiles could found here:
http://staff.vpac.org/~hsumanto/tile_x0_y0.nc
http://staff.vpac.org/~hsumanto/tile_x1_y0.nc
gdalwarp into nc4c with -dstnodata option:
Error encountered and output dataset viewed in QGIS is NOT OK
gdalwarp -tr 500.0 500.0 -t_srs EPSG:3112 -te -2576984.0 -5211665.0 1992016.0 -1219665.0 -r near -dstnodata 9.969209968386869E36 -of netCDF -co COMPRESS=DEFLATE -co ZLEVEL=6 -co FORMAT=NC4C -co WRITE_GDAL_TAGS=yes tile_x0_y0.nc tile_x1_y0.nc tile_combined-nc4c.nc Creating output file that is 9138P x 7984L. Processing input file tile_x0_y0.nc. Using internal nodata values (eg. 9.96921e+36) for image tile_x0_y0.nc. 0...10...20...30...40...50...60...70...80...90...100 - done. Processing input file tile_x1_y0.nc. Using internal nodata values (eg. 9.96921e+36) for image tile_x1_y0.nc. ERROR 1: netcdf error #-122 : NetCDF: Attempt to define fill value when data already exists. . at (netcdfdataset.cpp,SetNoDataValue,750) 0...10...20...30...40...50...60...70...80...90...100 - done.
gdalwarp into nc4c without -dstnodata option:
No error but output file when viewed in QGIS is NOT OK
gdalwarp -tr 500.0 500.0 -t_srs EPSG:3112 -te -2576984.0 -5211665.0 1992016.0 -1219665.0 -r near -of netCDF -co COMPRESS=DEFLATE -co ZLEVEL=6 -co FORMAT=NC4C -co WRITE_GDAL_TAGS=yes tile_x0_y0.nc tile_x1_y0.nc tile_combined-nc4c_withnodstnodata.nc
gdalwarp into geotiff:
No error and output file when viewed in QGIS is OK
gdalwarp -tr 500.0 500.0 -t_srs EPSG:3112 -te -2576984.0 -5211665.0 1992016.0 -1219665.0 -r near -dstnodata 9.969209968386869E36 tile_x0_y0.nc tile_x1_y0.nc tile_combined-tif.tif
Note: To view nc4c files with QGIS, you might have to convert nc4c into geotiff using gdal_translate as QGIS currently can not open nc4c files directly.
The QGIS screenshots are attached as well.

