Mercel Santos
Mercel Santos

Reputation: 37

Read and write a Netcdf file using R

How can I read and write the following file using R ?

https://www.dropbox.com/s/vlnrlxjs7f977zz/3B42_daily.2012.11.23.7.nc

In other words, I would like to read the "3B42_daily.2012.11.23.7.nc" file and write with the same structure that it is written.

Best regards

Upvotes: 0

Views: 2039

Answers (1)

plannapus
plannapus

Reputation: 18759

Package ncdf have functions to do this. You should also read other Q&A on this site tagged with and .
Basically to read a netcdf file:

library(ncdf)
a <- open.ncdf('your/path/to/your/file.nc') #that opens a connection to the file

Then function get.var.ncdf helps you extract the data, variable by variable.

The process to write one is described in this Q&A.
The idea is to create dimensions first using dim.def.ncdf then the variables with var.def.ncdf and finally the file itself using create.ncdf.

Upvotes: 1

Related Questions