How to write text files to netcdf files

I have text files, each file has the name "pr_lat_lon", for example, "pr_30.25_125.25", "pr_30.25_125.75", "pr_30.75_125.25", "pr_30.75_125.75", etc. Each text file has just one column, which is the value for each day. They are daily data from 1950 to 2010 at each grid centroid. How to write each text file as a netcdf in R? Thanks for your help.

I read the data like this:

timespan = length(seq(as.Date('1950-01-01'),as.Date('2010-12-31'),by='day')) # which gives 22280

pr_30.25_125.25= data.frame(V1=rnorm(1:22280))
pr_30.25_125.75= data.frame(V1=rnorm(1:22280))

Could anyone help with my question? Thanks very much.

Have you seen this stack overflow thread?

I have not seen it. But thanks, it helps now.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.