
Write or Append Variables to a NetCDF File
write_netCDF.Rd
This function creates a new NetCDF file or opens an existing one, then writes the provided variables, dimensions, and associated attributes.
Usage
write_netCDF(
var_list,
var_attr,
xdim,
ydim,
tdim,
xattr,
yattr,
tattr,
fillvalue = 1e+32,
compression,
out_file
)
Arguments
- var_list
A list of variables to write to the NetCDF file.
- var_attr
A list of variable attributes. Each element in the list corresponds to a variable in `var_list` and contains its metadata (e.g., units, descriptions).
- xdim
A numeric vector representing the x-dimension values (e.g., longitude).
- ydim
A numeric vector representing the y-dimension values (e.g., latitude).
- tdim
A numeric vector representing the time dimension values.
- xattr
A named list of attributes for the x-dimension (i.e., `name` ,`long_name`, `units`, `axis`).
- yattr
A named list of attributes for the y-dimension (i.e., `name` ,`long_name`, `units`, `axis`).
- tattr
A named list of attributes for the time dimension (i.e., `name` ,`long_name`, `units`, `axis`, `calendar`).
- fillvalue
A numeric value to represent missing or undefined data. Defaults to `1e32`.
- compression
An integer specifying the level of compression to apply to the NetCDF file (typically 0-9).
- out_file
A string specifying the path to the NetCDF file. If the file exists, the function opens it to append variables; otherwise, it creates a new file.