Read data from a netCDF file
nc_get_variable.Rd
Read values of a given variable from a netCDF file or NetCDF
object.
If variable
is 2D the data.frame
has (x, y, t, value) columns.
If variable
is 3D the data.frame
has (x, y, z, t, value) columns.
Names of dimensions are preserved from input archive.
Arguments
- input
Path to NetCDF single file, list of files or directory with
NetCDF
files. It can also be a single or a list ofNetCDF
objects read byRNetCDF::open.nc
.- variable
character vector with the name of the variable to be read.
- tz
optional character string with time zone (default = "UTC").
Details
All netCDF
functions in AirVeg
are compatibile with the CF
convention and
IO/API data files (ex. CMAQ). We assume that data are on horizontally-regular grids.
According to NetCDF Climate and Forecast (CF) Metadata Conventions,
if the time zone is omitted the default is UTC.
In order to deal with special cases or with archives not compliant with CF
convention, the optional timezone
argument is provided to force it.
timezone
must be included in the Olson database. OlsonNames
function
(in the base
package) provides a list of known locations.
Attention: in order to set UTC+1 (without automatic switching of DST) the ETC/GMT-1 string must be specified.
Examples
if (FALSE) {
concfile <- c("extdata/conc_farm.nc")
no2 <- nc_get_variable(input = concfile, variable = "c_NO2", tz = "Etc/GMT-1")
}