jeudi 16 juillet 2015

Netcdf in R. Part 1: Installation in Linux debian based (ubuntu, linux mint)

Many scientific data (remoted sensed data, environmental, etc..) are distributed in NetCDF (nc format, .nc).
In R, the most used package to process these data is ncdf4 but it requires some other LINUX packages to be installed correctly in R.

The required packages are libnetcdf-dev, libnetcdfc++4, libnetcdfc7, libnetcdff5, libcf0, netcdf-bin

These required packages can be installed using apt-get install, Synaptic or Software Manager. If they aren't installed you can have errors such if you try to install ndcf4 in R

ERROR: configuration failed for package ‘ncdf4’ 

ncdf.c:3:20: fatal error: netcdf.h: No such file or directory
 #include <netcdf.h>
compilation terminated.
make: *** [ncdf.o] Error 1
ERROR: compilation failed for package ‘ncdf4’

After installing these requirements you can install now ncdf4 in R (install.packages('ncdf4')

In the next post, I'll give some useful tips to explore ncdf files in R.