Opened 13 years ago

Closed 12 years ago

#4221 closed enhancement (fixed)

Support Create() method for NetCDF driver so that gdalwarp can be used on a netcdf file

Reported by: pds Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: NetCDF, Create, IO
Cc: etourigny

Description

We'd like to be able to use gdalwarp functionality with NetCDF files as an output, which requires supporting the Create() and IWriteBlock() methods for the NetCDF driver.

The NetCDF C API supports creating a file with empty variables, then later updating an existing file, and random-access writing, all prerequisites for the Create() method in GDAL.

This should likely involve refactoring the GDAL driver so common functionality is shared between the Create() and CreateCopy() methods.

Change History (9)

comment:1 by Even Rouault, 13 years ago

Cc: etourigny added

comment:2 by etourigny, 12 years ago

Re-factored the driver and added a Create() function, commited to trunk (r23456), and autotests (r23457).

Significant changes brought by this commit:

  • removed vars that are used temporarily (e.g. panBandZLev)
  • Set* functions write to netcdf file when in update mode
  • Create() and CreateCopy() common functionality in CreateLL()
  • write bands now in IWriteBlock()
  • bottom-up = FALSE by default
  • updated all sprintf to (%.8g / %.16g) because of projection parameter precision differences

comment:3 by etourigny, 12 years ago

committed small fixes to trunk (r23458, r23459, r23460)

comment:4 by Even Rouault, 12 years ago

Etienne, you might want to check the correctness of the first part of the following fix :

r23461 /trunk/gdal/frmts/netcdf/netcdfdataset.cpp: Fix compiler warnings about wrong enum comparison, and uninitialized variable

comment:5 by etourigny, 12 years ago

Fix is fine, thanks. It worked before by chance, because NC_BYTE and GDT_Byte have the same value.

r23463: Added autotest for Create() and CreateCopy() a band with unsigned byte data and fix to PIXELTYPE metadata when calling Create().

comment:6 by etourigny, 12 years ago

In GDAL Byte data is unsigned by default and uses PIXELTYPE=SIGNEDBYTE metadata to specify signed byte, following

http://trac.osgeo.org/gdal/wiki/rfc14_imagestructure

Byte data in netcdf is by default signed, and the following conventions are used by the driver to specify unsigned byte

comment:7 by etourigny, 12 years ago

Using gdalwarp on a large dataset with -co COMPRESS=DEFLATE option (which forces NC4C format) does not work (takes a very long time). This is probably due to wrong chunksize, which was optimized for CreateCopy(). Exporting without compression works, so use that for now.

comment:8 by etourigny, 12 years ago

r23635 : properly enable chunking in netCDFDataset::DefVarDeflate() (#4404 and #4221)

comment:9 by etourigny, 12 years ago

Resolution: fixed
Status: newclosed

closing this ticket, see related bugs #4404 and #4432

Note: See TracTickets for help on using tickets.