The R raster package and GDAL both have independent wrappers around NetCDF-4* that treat an array variable as a "complete" dataset, i.e. they provide objects or interfaces that seamlessly give access to a variable inclusive with:

  • dimension variables
  • coordinate system metadata
  • value units
  • general other metadata

* I'm also interested in HDF4 and HDF5 extensions, but it seems less likely than for NetCDF-4.

I often see code that uses these at the lowest level, and I'm hoping to find more examples like those in raster and GDAL that have abstracted this away:

## psuedo code
load NetCDF
nc = open("file.nc")

v = getvar(nc, "somevariable")

x = getvar(nc, "somevariable_lon")
y = getvar(nc, "somevaraible_lat")


In R's raster and in GDAL it is much more like an extension of a traditional GIS raster, i.e. all the spatial context and metadata is present, and it extends to 3D and above. (There are problems with different conventions for rectilinear and curvilinear coordinates, but that's not my concern here).

Are there other open-source examples in widely used languages that provide the high-level interfaces like R's raster and GDAL?

Is there capacity in the NetCDF library itself for this higher level access? (I know how to use the lower level to build this, I want existing examples).

I'm also excluding uses of GDAL in Python, Perl, C# etc. - that is all just GDAL as far as I'm concerned. I'm also not interested in GIS interfaces that provide these via GDAL.


GDAL: http://www.gdal.org

edit (2017):

Python's xarray is a good example

  • raster is not using GDAL, as far as I know. It is wrapping functions from ncdf package or, if available, ncdf4. – user32309 Aug 4 '14 at 4:00
  • That is right, I didn't mean to imply that. I want analogues to raster or GDAL. But, actually it would use GDAL if neither ncdf or ncdf4 were available and NetCDF were built in to GDAL. But not relevant really – mdsumner Aug 4 '14 at 7:24

Well, the official Python wrappers for NetCDF4 are here:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.