NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdfgroup] RNetCDF - R package

I am looking for some guidelines on how to create a multidimentional netcdf
in R.
None of the examples given by the Reference Manual (
http://cran.r-project.org/web/packages/RNetCDF/index.html) is working for
me.

My data consists of daily climatic variables and I have the geographic
coordinates

nc <- create.nc("outputfile.nc")
## Create 3 dim
dim.def.nc( nc,"Long", length(x) )
dim.def.nc( nc,"Lat", length(y) )
dim.def.nc( nc,"Time", 15 )

## Create 4 vars
var.def.nc(nc, "Long", "NC_DOUBLE", "Long")
var.def.nc(nc, "Lat", "NC_DOUBLE", "Lat")
var.def.nc(nc, "Time", "NC_INT", "Time")
var.def.nc(nc, "Precipitation", "NC_DOUBLE",c(0,1,2))


att.put.nc(nc, "Precipitation", "missing_value", "NC_DOUBLE", -99)#.99)
mytime= as.vector(1:5)
var.put.nc(nc, "Time", mytime)

for (i in 1:500){
var.put.nc(nc,
"Precipitation",wstation.data.list[[i]][1:15],c(i,i,1),c(1,1,15))}

var.put.nc(nc, "Long", x)
var.put.nc(nc, "Lat", y)

close.nc(nc)

This is the output info in Panoply
 File "outputfile.nc"

Dataset type: NetCDF classic format
------------------------------

netcdf file:/E:/outputfile.nc {
 dimensions:
   Long = 1147;
   Lat = 1147;
   Time = 15;
 variables:
   double Precipitation(Time=15, Lat=1147, Long=1147);
     :missing_value = -99.0; // double
   double Long(Long=1147);
   double Lat(Lat=1147);
     :_CoordinateAxisType = "Lat";
   int Time(Time=15);
     :_CoordinateAxisType = "Time";

 :_CoordSysBuilder = "ucar.nc2.dataset.conv.DefaultConvention";
}
  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: