create.ncdf {ncdf} | R Documentation |
Creates a new netCDF file, given the variables the new file is to contain.
create.ncdf( filename, vars, verbose=FALSE )
filename |
Name of the netCDF file to be created. |
vars |
Either an object of class var.ncdf describing the variable to be created, or a vector of such objects to be created. |
verbose |
If TRUE, then information is printed while the file is being created. |
This routine creates a new netCDF file on disk. It must be given the variables in
the file that will be created.
Keep in mind that the new file may not actually be written to disk until
close.ncdf
is called.
An object of class ncdf
, which has the fields described in open.ncdf
.
David W. Pierce dpierce@ucsd.edu
http://www.unidata.ucar.edu/packages/netcdf/
# Define an integer dimension dimState <- dim.def.ncdf( "StateNo", "count", 1:50 ) # Make an integer variable. Note that an integer variable can have # a double precision dimension, or vice versa; there is no fixed # relationship between the precision of the dimension and that of the # associated variable. We just make an integer variable here for # illustration purposes. varPop <- var.def.ncdf("Pop", "count", dimState, -1, longname="Population", prec="integer") # Create a netCDF file with this variable ncnew <- create.ncdf( "states_population.nc", varPop ) # Write some values to this variable on disk. popAlabama <- 4447100 put.var.ncdf( ncnew, varPop, popAlabama, start=1, count=1 ) close.ncdf(ncnew)