% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/writeNC.R
\name{writeNC}
\alias{writeNC}
\title{Save data to a NetCDF file}
\usage{
writeNC(data, res, ext, date, vars, varunit, contact, institute, filename)
}
\arguments{
\item{data}{\code{list}. data.frame or list of data.frames according to the length of the variables.}

\item{res}{\code{numeric}. Resolution of the output file.}

\item{ext}{\code{extent}. If present the NetCDF file is subset by this extent.}

\item{date}{\code{numeric}. Date(s) of input data which should be written to file.}

\item{vars}{\code{character}. Variables included in output file.}

\item{varunit}{\code{character}. Unit of variable output.}

\item{contact}{\code{character}. Contact information of author.}

\item{institute}{\code{character}. Institute affiliation of author.}

\item{filename}{\code{character}. Name of output file.}
}
\value{
A raster stack with monthly layers of aggregated data over the specified time period and area.
}
\description{
Save data to a NetCDF file
}
\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)
}
