Create a netCDF File
Creates a new netCDF file on disk, given the variables the new file is to contain.
nc_create( filename, vars, force_v4=FALSE, verbose=FALSE )
filename |
Name of the netCDF file to be created. |
vars |
Either an object of class |
force_v4 |
If TRUE, then the created output file will always be in netcdf-4 format (which supports more features, but cannot be read by version 3 of the netcdf library). If FALSE, then the file is created in netcdf version 3 format UNLESS the user has requested features that require version 4. Deafult is FALSE. |
verbose |
If TRUE, then information is printed while the file is being created. |
An object of class ncdf4
, which has the fields described in nc_open
.
David W. Pierce dpierce@ucsd.edu
http://dwpierce.com/software
# Define an integer dimension dimState <- ncdim_def( "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 <- ncvar_def("Pop", "count", dimState, -1, longname="Population", prec="integer") # Create a netCDF file with this variable ncnew <- nc_create( "states_population.nc", varPop ) # Write some values to this variable on disk. popAlabama <- 4447100 ncvar_put( ncnew, varPop, popAlabama, start=1, count=1 ) nc_close(ncnew) # Clean up example file.remove( "states_population.nc" )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.