0

I need to regrid hundreds of netCDF files but when I used the CDO command in R, there is always a problem like this:

cdo remapnn (Abort): Too few streams specified! Operator needs 1 input and 1 output streams.

the code is as follows:

files <- list.files(path = common_path,pattern = ".nc")
cdo_path   = '/opt/local/bin/cdo'

new_data_folder = "test_r"
raw_data_folder = "data"

for (i_file in files) {
  raw_file <- paste(raw_data_folder,i_file,sep = '/')
  new_file <- paste(new_data_folder,i_file,sep = '/')
  system(paste(cdo_path,' remapnn,r720x360 ',raw_file,new_file,sep="")) 
}
ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Hong
  • 49
  • 6
  • Maybe add a space between `raw_file` and `new_file`? `system(paste(cdo_path, ' remapnn,r720x360 ', raw_file, " ", new_file, sep = ""))` – Tung Aug 27 '18 at 15:57
  • When in doubt always print out the command first to double check i.e. `print(paste(cdo_path, ' remapnn,r720x360 ', raw_file, " ", new_file, sep = ""))` – Tung Aug 27 '18 at 15:58
  • Thanks!I have figured it out. `system(paste(cdo_path,' remapnn,r720x360 ',raw_file,' ',new_file,sep = ""))` – Hong Aug 28 '18 at 23:58

1 Answers1

0

You could try this:

system(paste(cdo_path,' remapnn,r720x360 ',raw_file,' ',new_file,sep = ""))
Hong
  • 49
  • 6