NetCDF (.nc)

Background & Context

    • MIME type: application/x-netcdf
    • NetCDF data file format.
    • Self-describing format for exchanging scientific data.
    • Used in atmospheric research, GIS, and related fields.
    • NetCDF is an acronym derived from network Common Data Form.
    • Binary file format.
    • Conceptually based on NASA's Common Data Format, but incompatible with this format.
    • Developed by the Unidata center at the University Corporation for Atmospheric Research (UCAR).

Import & Export

  • Import[""] imports a netCDF file, returning the names of the datasets stored in the file.
  • Export["",expr] exports a data array to a netCDF file.
  • Import[""] returns a list of strings representing the names of all datasets contained in the file.
  • Export["",{expr1,}, {"Datasets",{"/dataset1",}}] creates a netCDF file, storing the data arrays {expr1,} as separate datasets.
  • Import["",elem] imports the specified element from a netCDF file.
  • Import["",{elem,suba,subb,}] imports a subelement.
  • Import["",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","NetCDF"] or Import["file",{"NetCDF",elem,}].
  • Export["",expr,elem] creates a netCDF file by treating expr as specifying element elem.
  • Export["",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
  • Export["",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the netCDF format.

Import Elements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Data"all datasets imported as a list of arrays
    "Datasets"names of all datasets
  • Import by default uses the "Datasets" element for the netCDF format.
  • Specifying and selecting datasets:
  • "Datasets", nn^(th) dataset
    "Datasets", datasetnamed dataset
  • Meta-information elements:
  • "Annotations"meta-information for each dataset
    "DataFormat"type used to represent each dataset
    "Dimensions"data dimensions of each dataset
    "Metadata"general meta-information as a list of rules
  • The following values can be given for "DataFormat":
  • "Integer8"8-bit integers
    "Integer16"16-bit integers
    "Integer32"32-bit integers
    "UnsignedInteger8"unsigned 8-bit integers (Export only)
    "Real32"IEEE single-precision numbers
    "Real64"IEEE double-precision numbers
    "String"strings of ASCII characters


Basic Examples  (4)

Get the names of datasets stored in a netCDF file:

Import a dataset:

Render the imported data as graphics:

Read meta-information from a netCDF file:

Export raster image data to the netCDF format:

This gives the names of the datasets stored in this file: