NetCDF Improvements

This page is for information regarding improvements to the GDAL NetCDF driver.

For information on the current NetCDF driver, please consult:


UNIDATA NetCDF Conventions

UNIDATA recommends the use of the CF Conventions (NetCDF Climate and Forecast (CF) Metadata Conventions) where applicable.
It is intended that this driver fully support the CF-1.5 Conventions for import and export and COARDS for import. Provisions should be taken for back-wards compatibility with different CF-1.x versions.

Issues with the current implementation

  • NetCDF created by GDAL not CF-1.0 compliant for geographical grids (issue #2129)
  • netcdf driver does not read and write CF-1.0 coordinate system properly for projected CRS (issue #2893) - mostly fixed in trunk and 1.9
    • support for read and write of projected coordinate values
    • export std_parallel variables into a single standard_parallel netcdf attribute
    • add proper datum import and export support
    • issues with specific projections (see wiki:NetCDF_ProjectionTestingStatus and generic report in #2893):
      • rotated_pole (#4285 and #4251)
      • Stereographic vs. Oblique_Stereographic (#4267)
      • LCC1SP - no scale_factor in CF-1 (#3324)
      • CEA : how to deal with scale_factor_at_projection_origin vs. of standard_parallel1
      • PS: how to deal with standard_parallel vs. scale_factor_at_projection_origin
  • add CF compliance checker to the autotests (issue #4233)
  • support "coordinates" attribute (and associated curvilinear grid) for projections which are not supported by GDAL/PROJ.4 (i.e rotated pole) (issues #4285 and #4251)


GDAL and NetCDF support metadata in different ways, which should be harmonised.

Issues with the current implementation

  • The import process does not use the Conventions attribute and does not consider different possible Conventions (COARDS, CF-1.0, CF-1.5, etc.)
  • netcdf history global attribute should be updated. no mecanism for saving commands in gdal, due to security issues (issue #4297)
  • implement setmetadata and setmetadataitem, tricky because other nc attributes are already written to file

Issues that have been resolved (in trunk and 1.9)

  • Duplication in Metadata when translating from NetCDF to NetCDF (issue #4204)
  • metadata from a NetCDF variable should be stored inside the GDAL Band metadata, instead of a global metadata item (issue #4211)
  • NetCDF variable name is lost when imported into GDAL (issue #4211)
  • Floating-point metadata in netcdf file is converted to GDAL metadata as string without sufficient precision (issue #4211)
  • GDAL version saved in GDAL global attribute
  • CF-version of file read could be kept in an internal variable, as well as CF-version for file creation - in trunk and 1.9 CF-1.5 is exported to file only

Datum issues

CF supports Datum information but does not specify how datum ids (such as those found in EPSG codes) should be stored in the netcdf file

  • Which datum should be set when there is no datum information at all in a netcdf file? WGS84 or none?
  • How to export datum information that is present in a GDAL file, in a way that it can be restored later? - current codes uses spatial_ref
  • Import should correctly set appropriate CRS/datum information (e.g. WGS84) from the information in the netcdf file, when sufficient information is available. - in trunk and 1.9 compares WKT and CF grid_mapping and checks for conflict. There are issues with auto-detecting named CRS/datum based on spheroid only.

Dimension/grid issues

  • The driver should handle properly a time and Z-axis in a way that they they are not lost when importing and exporting (bug #2581)
  • Add support for irregular grids (bug #1894)
  • Check the axis attribute on the dims to determine the correct order (instead of assuming the order of x, y, z, t)
  • Irregular grid testing: use a fraction threshold, not an absolute amount (0.1 degrees at present).

I/O issues

  • Disabled PAM support, as it created incompatibilities and metadata duplication. Will re-enable once things are settled PAM has been re-implemented to store raster statistics only - #4244 and #4245
  • Support Create() method so that gdalwarp can be used on a netcdf file - #4221 (committed to trunk)
  • Fix access to different netcdf file types: nc (classic), nc2 (64-bit) and nc4 (NetCDF4 with HDF5 support) - #3890 and #2379
  • Add option for file type (nc,nc2,nc4) at export (#3166)
  • Support compressed netcdf (DEFLATE with NC4 or NC4C) (#4404, #4221)
  • fix the y-axis for import and export (issues #4251 and #4284)
  • support packed data (with add_offset and scale_factor) transparently (see bug #3797) - will not implement
  • support for signed/unsigned Byte data - #4221
  • Ignore coordinate and bounds variables (CF sections 5.2, 5.6 and 7.1) as raster bands, but expose them as subdatasets - this allows to open files with projected SRS (or dimension bounds) directly, without specifying the variable as a subdataset (added in r23977)


Various bugs / wishlist / questions

  • can we define dim vars before band vars, without performance hit? ncenddef??
  • should we set NO_FILL for performance gain? nc_set_fill(ncid, NC_NOFILL, &old_fill_mode);
  • remove stdp1 from lcc-1sp
  • fix metadata access, unique way (fetchcopy parm, NCDFGetAttr, getmetadata, CSLFetchNameValue(poDS->papszMetadata, szTemp); )
  • fix warnings (???)
  • add NCDF_DEBUG option (and supporting function) to supress most debugging output unless specified

Back-porting to 1.8 branch

  • metadata and precision fixes ( #4200, #4204, #4211, #4244 )
  • import of NC2, NC4, NC4C, HDF4 (#3890, #2379, #4294 and #3166)
  • fix GT import issue (fixed in trunk r23263)
  • fix import of projected srs (fixed in trunk r23263 and others)
  • fix CF-export of geographic and projected srs(#2129 and #2893)
  • add GDAL version to netcdf metadata (for detection of bottom-up c.f. r23263)

Compatibility with other software

The driver should be compatible for import and/or export (with proper visualisation) with at least the following software:

  • ncdump from UNIDATA netcdf
  • CF compliance checker
  • ncview
  • GrADS - Grid Analysis and Display System
  • CDO - Climate Data Operator
  • NCO - netCDF Operators
  • TDS - THREDDS Data Server (i.e. ensure its WCS and WMS capabilities work)
    • ncWMS - ncWMS is the package that TDS uses for WMS presentation of NetCDF files, also includes the GODIVA web viewer for same.
  • others to come...

Test files

A place should be set up to store NetCDF sample files, provided they are free under the terms of .
Large files will be available at .
Having small (typically < or ~ 10 KB ) sample files is also good so they can be directly included in SVN under the autotest/gdrivers/data directory and thus easily used by regression tests.


  • Contributors are welcome and could be identified here in 3 categories: Ideas/reporting, testing, and/or development.
  • Discussions can take place here or the mailing list with the title "NetCDF Improvements"
  • Tickets can be used to track the implementation of specific items and bugfixes.
  • Backward compatibility issues, in particular with respect to files produced by older GDAL versions, might require voting, as in details

Proposed changes that affect interface or backward compatibility

(Note: this linked page may be turned into an RFC if needed)


I (etiennesky) have created this wiki entry after a discussion in the gdal-dev mailing list (Subject: discussion on improvements to the NetCDF driver and CF-1 convention). Even made a number of suggestions which I have followed (I also shamelessly copied some of his wording).
I encourage interested parties in participating in this discussion here and in the mailing list. In particular, it would be useful to collect information on contributors and obtain test files with issues and the expected outcome. Simple files can also be included in order to test for regression issues in the future.

Regards, etiennesky - Aug. 28

Open Tickets

No results

Closed Tickets

NetCDF segmentation fault
gdalinfo on a netCDF file returns incorrect coordinates
gdalinfo on a netCDF file returns uninitiated coordinate information if variable/band not specified
problems reading etopo2v2 (arc grid, / GMT (netcdf) /HDF)
patch for 1.4.x : frmts/netcdf (NC_GLOBAL#{spatial_ref/GeoTransform})
add support for scale and offset in netCDF driver.
NetCDF driver confused by paths with drive letters
NetCDF Driver Improvements
NetCDF file lacks georeferencing
Corrects for the wrong header info printed by gdalinfo on GMT grids and the ReadAttributes method issue
use of uninitialized memory in netCDFDataset::SetProjection
NetCDF created by GDAL not CF-1.0 compliant for geographical grids
NetCDF driver segfaults when reading large attributes
GDAL with NetCDF4 - Adjustment to recognize netCDF4
[PATCH] Band selection in NETCDF driver
netcdf: add metadata record for original array dimension when reading from multidimensional files
five dimensional netcdf file crashes gdalinfo on windows
[PATCH] five dimensional file image access fails for some dimensions
NetCDF Global EASE-Grid 8-day Blended SSM/I and MODIS Snow Cover flipped east/west?
NetCDF Driver should read/write data in stripes instead of the whole array
accessing NetCDF band data of type char causes errors
[PATCH] Fix flipped latitude with NetCDF CF-1 files
--with-netcdf=diretory does not really test netcdf
flipped NetCDF driver output
netcdf driver does not read and write CF-1.0 coordinate system properly for projected CRS
Configure snippet is not truly able to manage both netcdf3 and netcdf4
can't make large/64-bit netCDF file
unable to compile 1.6.2 w/ netcdf, hdf
Add Lambert Conformal Conic single standard parallel support to netCDF driver
Add new projections from cf-1.4 to netcdf driver
Lambert_Conformal_Conic_1SP incorrectly read as Lambert_Conformal_Conic_2SP by netcdf driver
netCDF for western hemisphere
netCDF for western hemisphere
GDAL's NetCDF driver doesn't seem to read the spatial reference system as documented
netCDF driver ignores the "scale_factor"
Error while reprojecting with gdalwarp an ECMWF netCDF
netCDF file reading error
Configuring gdal 1.8.0 with hdf and netcdf at the same time fails
Problem creating netcdf files with numerous bands
gdal_translate segfault when translating ERS to NetCDF.
upside flipped NetCDF
[PATCH] gdal_translate GeoTIFF to NetCDF results in coordinates shifting
Duplication in Metadata when translating from NetCDF to NetCDF
Support Create() method for NetCDF driver so that gdalwarp can be used on a netcdf file
netcdf: add CF compliance checker to the autotests
PAM stores duplicate metadata even if the format and driver support
netcdf driver does not support rotated_pole projection
Change netcdf driver to read and write in the bottom-up order by default
OGR does not support PROJ.4 +proj=ob_tran , rotated_pole is not supported by the netcdf driver
changes to the netcdf driver export and import
add support for "history" metadataitem which keeps track of all GDAL command line operations
Issue with netcdf driver and srs units
gdal_translate GeoTIFF to NetCDF with NC4 DEFLATE compression is taking forever
Error reading netCDF dataset
GDAL configure doesn't pick up NetCDF4 in latest Ubuntu 11.10
configure script does not support static netcdf build
gdal_rasterize produces error when burning vector dataset into netCDF dataset directly with -a_nodata nan
lack of closing read-only dataset dataset or calling GDALDestroyDriverManager() on NC4C (netCDF-4 classic model) file producing HDF5-DIAG error messages
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
netcdf files with longitude between 180 and 360 degrees are incorrectly projected
netcdf driver does not support irregular grids / GDAL GEOLOCATION arrays
netcdf driver does not keep original latitude values for Gaussian grids
gdalwarp does not properly close datasets in error conditions, can output errors in shared library unloading
NCDFAddGDALHistory() uses free'd memory
NetCDF driver assumes 'x' 'y' to be names of dimension variables
NetCDF driver writes incorrect GeoTranform in case of WRITE_BOTTOMUP=YES
PATCH: DODS driver can now read 3-D datasets, metadata, projection, remote NetCDF files
onestep vs twosteps warping to netcdf
duplicate nodata metadata in netcdf files copied with gdal_translate
netcdf driver incorrectly calculates geotransform
NetCDF driver doesn't recognize grids as uniform.
netcdf driver does not detect .grd files in netcdf-4 format / netcdf driver does not support netcdf-4 files with default chunking and bottom-up format / hdf5 driver crashes when H5Sget_simple_extent_ndims() returns negative value
NetCDF: gdal_translate unable to translate EASE-GRID file properly
gdal HDF5 NetCDF plugin bug
netcdf driver does not detect "top-down" order
GTiff to netcdf conversion fails
[PATCH] netCDF: optimize IReadBlock() and CheckData() handling of partial blocks in the x axis
gdalinfo segmentation fault reading NetCDF + CF grid
netCDF classic reports negative nodata value for unsigned byte > 127
Buffer overflow potential in netcdf driver
1 byte heap write overflow in NCDFTokenizeArray()
netCDF: lack of validation that gridmapping:GeoTransform has 6 values
NCDFIsGDALVersionGTE(): lack of input validation
gdalinfo and gdal_translate seg faulting for unsigned short variables in netcdf file
allow vector read of NetCDF NASA ocean color L3Bin files
gdal_translate returning PROJCS "unnamed" for lambert_cylindrical_equal_area
segfault in NCDFGet1DVar
SM2RAIN-ASCAT global precipitation netcdf file cannot be read
Using H5S_MAX_RANK rather than hard coded 32?
NetCDF crashes ogrinfo and QGIS.

Last modified 12 years ago Last modified on Feb 14, 2012, 1:39:43 PM
Note: See TracWiki for help on using the wiki.