简体   繁体   中英

Merging multiple NetCDF files in R

Discretion: I'm fairly new to using NetCDF files and R. I have 96 individual.nc4 files for monthly global air temperature from 1901 to 2010. They have the same dimensions for lon, lat, and time, and the variable is monthly air temperature. I would like to merge all 96 files into a singular.nc4 file so that I could use it as driver data in a model I am running. I have written the following code:

enter image description here

However, it keeps returning the following error message:

Error in ncvar_def("Tair_monthly", "k", "time") : 
  This dim has class: character

Not sure how to get around this so would love any advice on 1) what this error means and how to solve and 2) generally how to merge multiple NetCDF files in R

If you are new to netCDF it is possibly better to learn the command line tool CDO. It will be able to merge files much more easily than anything available in R. To merge your files you would just need to do:

cdo mergetime *.nc merged_tai.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