Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to run CDO within a R script?

Tags:

r

cdo-climate

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

like image 872
user3231352 Avatar asked Jun 19 '16 18:06

user3231352


1 Answers

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=(" ")))
like image 73
Forever Avatar answered Oct 10 '22 20:10

Forever