write_netcdf: Function to write results from downscalr or other sources...

View source: R/write_netcdf.R

write_netcdfR Documentation

Function to write results from downscalr or other sources into netCDF file format

Description

Function to write results from downscalr or other sources into netCDF file format

Usage

write_netcdf(
  data = NULL,
  rasterfile = NULL,
  variables = list(name_long = "This is long name", name = "this_is_standard_name", units
    = "unit_of_measurement", dimname = "dim_name", varn = NULL, timen = NULL, expandValue
    = 0, data = NULL, vardescr = NULL, create.dimvar = TRUE),
  start.time = NULL,
  end.time = NULL,
  by.time = 10,
  filename = NULL,
  filepath = NULL,
  verbose = FALSE
)

Arguments

data

If not provided in variables, either a dataframe or matrix object with columns ns (raster cell numbers), times (optional), var1 (variable levels), and value; defaults to NULL

rasterfile

Raster grid object with ns as cell values

variables

A list of lists for each variable to be written or if data is provided a list of netCDF attribute settings as follows:

  • data = a data frame object with columns ns (raster cell numbers), times (optional), var1 (variable levels), and value. Overridden if argument data is provided, defaults to NULL

  • name_long = character string specifying a long descriptive name; defaults to name_long="This is long name"

  • name = character string specifying the standard name, contains no white space and is case sensitive : defaults to name="this_is_standard_name"

  • units = character string specifying the unit of measure of data; defaults to units="unit_of_measurement"

  • varn = integer specifying the number of levels of variable; defaults to NULL

  • timen = integer specifying the number of timesteps

  • expandValue = numeric value or NA to fill in missing observations in data

  • vardescr = character string providing longer description of variable levels in data; defaults to NULL

  • create.dimvar = either TRUE or FALSE, defines if dimension variable of data should be created or not; defaults to TRUE

start.time

Integer defining first time step of time dimension to write, if dimension times is provided in data or variables, ; defaults to min(data$times) per variable

end.time

Integer defining last time step of time dimension to write, if dimension times is provided in data or variables, ; defaults to min(data$times) per variable

by.time

Integer specifying interval of time steps to be written between start.time and end.time; defaults to 10

filename

Character string of netCDF file name, has to include ".nc" extension; defaults to filename="Downscale_netCDF.nc"

filepath

Character string to specify file path netCDF is written to, defaults to current working directory

verbose

Either TRUE or FALSE, prints each layer written into the netCDF file (for troubleshooting purposes); defaults to FALSE

Value

  • Outputs ‘netCDF’ file with filename written into filepath as specified in function arguments


tkrisztin/downscalr documentation built on June 2, 2025, 1:16 a.m.