user3231352
user3231352

Reputation: 809

is it possible to run CDO within a R script?

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

Upvotes: 8

Views: 3453

Answers (2)

Forever
Forever

Reputation: 545

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=(" ")))

Upvotes: 2

ClimateUnboxed
ClimateUnboxed

Reputation: 8087

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

Upvotes: 2

Related Questions