writeNC: Save data to a NetCDF file

View source: R/writeNC.R

writeNCR Documentation

Save data to a NetCDF file

Description

Save data to a NetCDF file

Usage

writeNC(data, res, ext, date, vars, varunit, contact, institute, filename)

Arguments

data

list. data.frame or list of data.frames according to the length of the variables.

res

numeric. Resolution of the output file.

ext

extent. If present the NetCDF file is subset by this extent.

date

numeric. Date(s) of input data which should be written to file.

vars

character. Variables included in output file.

varunit

character. Unit of variable output.

contact

character. Contact information of author.

institute

character. Institute affiliation of author.

filename

character. Name of output file.

Value

A raster stack with monthly layers of aggregated data over the specified time period and area.

Examples

files <- list.files(paste0(system.file(package="processNC"), "/extdata"), 
                   pattern="tas.*\\.nc", full.names=TRUE)
data <- subsetNC(files, ext=c(8.5, 14, 47, 51), startdate=1990, enddate=1999)
data <- as.data.frame(data, xy=TRUE)
outfile <- tempfile(fileext=".nc4")
writeNC(data=data, res=0.5, ext=c(8.5, 14, 47, 51), 
        date=seq(as.Date("1990-01-01"), as.Date("1999-01-01"), by="day"), 
        vars="tas", varunit="in degree Celsius", contact="RS-eco <rs-eco@posteo.de>", 
        institute="Github", filename=outfile)
raster::stack(outfile)

RS-eco/processNC documentation built on Aug. 7, 2023, 8:12 a.m.