0

Is there a quick and easy way to take an existing RData file and convert it to netCDF? I have a large .RData file (~780 MB) with 88 variables, and all I can find online is how to make a netCDF file from scratch with simple examples that don't have a lot of variables. I'm trying to loop the 88 variables, but am getting errors because of the complexity. Is there a function that exists to do this in R? Thank you.

Cyndi
  • 1
  • I don't know that it would be possible to write a generic function that would do the right thing in all cases. Perhaps you could explain a bit more about the package you are using and the errors you are getting. – Ian Wesley Oct 24 '18 at 17:54
  • I'm using the ncdf4 library. First I load the RData file that I have, which creates "mydata2" in my global environment. "mydata2" has 1412729 obs. of 88 variables, such as latitude, longitude, country, region, urban, mean_PM2.5, etc. I do: vars<-names(mydata2) to get all of those listed, and then try to loop through them first to set all of the ncdim_def and then to do the ncvar_put. The errors I'm getting are often due to data being passed in in the wrong format. londim<-ncdim_def("lon","degrees",mydata2[vars[2]]), gives "Error in ncdim_def(...) Only numeric dimension values are supported" – Cyndi Oct 24 '18 at 18:17

0 Answers0