Introduction
NetCDF (Network Common Data Form) stores arrays of scientific data, such as temperature on a grid of latitude, longitude, height and time, together with the names, units and descriptions that explain them. It comes from Unidata, part of the University Corporation for Atmospheric Research in the United States, and has been developed since the late 1980s. It is the standard format for climate, weather and ocean data, usually following the CF (Climate and Forecast) conventions.
A NetCDF file holds dimensions, named lengths such as
time or lat; variables, arrays shaped by
those dimensions; and attributes, small values attached to a variable
or to the whole file. Two quite different file layouts carry this model, both usually
named .nc.
Variations
| Format | Variation | About | Open |
|---|---|---|---|
.NC | NetCDF classic | Gridded science data: a CDF header of dimensions and variables, then arrays. | Open |
.NC | NetCDF-4 | NetCDF data stored in an HDF5 file, with compression, chunks and groups. | Open |
NetCDF classic
The original layout, a simple header followed by the arrays, with a 64-bit offset version for files over 2 GB and a 64-bit data version (CDF-5) for larger arrays and more data types. It is still the most widely shared form.
The file starts with CDF and a version byte: 01 for the
classic format, 02 for 64-bit offset and 05 for 64-bit
data.
Reference: header and data.
NetCDF-4
Since NetCDF 4.0, data can be stored in an HDF5 file, which adds compression, chunking, groups, more types and several unlimited dimensions.
The file starts with the HDF5 signature 89 48 44 46 0D 0A 1A 0A.
Reference: HDF5 mapping.
Not described
Each variation lists its own gaps: classic (two open
reference questions, and the viewer’s remaining gaps: the parts of the CF conventions it does not check, such as
standard names, area types and the values of grid mapping parameters, and no map projection on the plot) and
NetCDF-4 (NCZarr’s Zarr version 3 support and registered filters
beyond those named, and the viewer’s gaps: no plot and no CF reading of a NetCDF-4 variable). The viewer reads classic
files (CDF-1, CDF-2 and CDF-5) with CF dates, flags, cell methods, climatology and grid mappings; a NetCDF-4 file
(an HDF5 file named .nc) is read through the HDF5 viewer and
presented as NetCDF groups, dimensions, variables, attributes and types, with the HDF5 structures kept beneath.
Links
Software
- Panoply – NASA’s free viewer that plots gridded data on maps (Windows, macOS, Linux)
- NetCDF utilities – Unidata’s
ncdump,ncgenandnccopycommand-line tools - QGIS – free GIS that loads NetCDF grids as map layers (Windows, macOS, Linux)
Developers
Reference
- NetCDF file format specifications – Unidata’s specifications of the classic and NetCDF-4 formats
- CF Conventions – the names and units used in climate and forecast data