7

I am working with netcdf files, and there are some analysis that I've been doing with CDO and then, with R. I would like to know if there would be possible to "call" the CDO directly from R, in the same script. I am not sure how (I have been trying with System() to invoke the commands..but I don't get it). Anyone has an idea about that?? Would it be possible??

Many thanks in advance

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
user3231352
  • 799
  • 1
  • 9
  • 26
  • 2
    Have you seen this [package](https://cran.r-project.org/web/packages/cmsaf/index.html)? – J_F Jun 19 '16 at 19:23
  • Yes, and actually it seems really good, but there are some functionalities that CDO can make and I didn't find them in that package. That's why I was interested in knowing if it's possible to run CDO within R. – user3231352 Jun 19 '16 at 19:46
  • The `system` function lets you run almost anything from R. The question is whether `` can interoperate. – IRTFM Jun 20 '16 at 01:12

2 Answers2

2

Since 2018, there is now a R package called "ClimateOperators" that allows you to use CDO and NCO operators directly from within R without resorting to system commands. Here is a link to the github repository:

https://github.com/markpayneatwork/ClimateOperators

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
1

Yes, using the system() function you can use bash (in Linux) along R normal routines

For example, a simple code to convert a GRIB2 file to NetCDF

file_grb2 = "001.grb2"
file_ncdf ="001.nc"
system(paste("cd ~/DATA/prate; cdo -f nc copy ",file_grb2,file_ncdf,sep=(" ")))
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Forever
  • 385
  • 3
  • 16