简体   繁体   中英

Merging many single .nc files into one multi-file netCDF using r?

I am trying to merge many single.nc files into one multi-file netCDF. I need to merge monthly files from 1901-2006 for a few variables eg temp (filename is tmp_cru-ts-4.03-gridded_1.75w50.75n1.75w50.75n_19010116)

My skills are pretty basic in R but I've tried this so far:

filenames=list.files("tmp", pattern = '*.nc', full.names = TRUE)
ldf = lapply(filenames,open.nc)             #rnetcdf function
binded = rbind(ldf)

I'm not sure if this is right, or how to now write it to a.nc file?

Thanks!

NCO can do this with ncrcat

ncrcat in*.nc out.nc

CDO can do this too

cdo cat in*.nc out.nc

or more robustly in this case where the files are for different times:

cdo mergetime in*.nc out.nc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM