Learn R Programming

meteoland (version 2.2.5)

write_interpolator: Write the interpolator object

Description

Write the interpolator object to a file

Usage

write_interpolator(
  interpolator,
  filename,
  .overwrite = FALSE,
  .verbose = getOption("meteoland_verbosity", TRUE)
)

Value

invisible interpolator object, to allow using this function as a step in a pipe

Arguments

interpolator

meteoland interpolator object, as created by create_meteo_interpolator

filename

file name for the interpolator nc file

.overwrite

logical indicating if the file should be overwritten if it already exists

.verbose

Logical indicating if the function must show messages and info. Default value checks "meteoland_verbosity" option and if not set, defaults to TRUE. It can be turned off for the function with FALSE, or session wide with options(meteoland_verbosity = FALSE)

Author

Victor Granda García, EMF-CREAF

Details

This function writes the interpolator object created with create_meteo_interpolator in a NetCDF-CF standard compliant format, as specified in https://cfconventions.org/cf-conventions/cf-conventions.html

See Also

Other interpolator functions: add_topo(), create_meteo_interpolator(), get_interpolation_params(), read_interpolator(), set_interpolation_params(), with_meteo()

Examples

Run this code

# \donttest{
# example interpolator
data(meteoland_interpolator_example)

# temporal folder
tmp_dir <- tempdir()

# write interpolator
write_interpolator(
  meteoland_interpolator_example,
  file.path(tmp_dir, "meteoland_interpolator_example.nc"),
  .overwrite = TRUE
)

# check file exists
file.exists(file.path(tmp_dir, "meteoland_interpolator_example.nc"))

# read it again
read_interpolator(file.path(tmp_dir, "meteoland_interpolator_example.nc"))
# }

Run the code above in your browser using DataLab