From GRASS-Wiki
Jump to navigation Jump to search

Both netCDF import and export in GRASS GIS are basically driven by the GDAL library. Note that GDAL library needs to be compiled with netCDF support to enable GRASS to read and write this format.

  • Due to important bug fixes in the NetCDF driver, it is strongly recommended to use GDAL version 1.9 or newer.

netCDF import

The important key to importing NetCDF raster file via is to specify the correct data subset in the input argument. NetCDF subset specifiers can be obtained from the output of gdalinfo.

For a file named


...will produce a lot of output, including lines that look like this:


The input argument to must contain all the information after the "=" in the format NETCDF:"[path to file in double quotes]":[variable name]. To import the time_bnds data from NetCDF file into GRASS, you need to specify the input as follows: input=NETCDF:"":time_bnds output=sst

The time_bnds subset may contain multiple data bands. Information about the bands in a subset can be obtained by running gdalinfo on just the subset

 gdalinfo NETCDF:"":time_bnds

...will produce output like this:

 Band 22 Block=180x1 Type=Float32, ColorInterp=Undefined
   NoData Value=1e+20
     NETCDF_time_units=days since 2001-1-1

You can specify the bands you want to extract using the bands= argument of

netCDF export

Sample datasets and mini-tutorial

Including conversion from global grid-registration to cell-center registration by cropping off northern, southern, and western rows of cells, then using r.region to set remaining in-bounds cell outer boundaries.

  • (contributions welcome)