Extracts a subset of a variable from a netCDF file using coordinate bounds supplied for one or more dimensions, and writes the result to a new file.
Usage
nc_subset(
filename,
varid,
output,
newvarid,
compression,
force_v4 = FALSE,
...,
ignore.case = FALSE,
drop = FALSE
)Arguments
- filename
Character string giving the path to the input netCDF file.
- varid
Character string giving the name of the variable to subset. If missing and the file contains a single variable, that variable is used.
- output
Character string giving the path to the output netCDF file to create.
- newvarid
Optional character string giving the name of the variable in the output file. By default, the original variable name is used.
- compression
Optional numeric compression level for the output variable. Supplying this typically requires netCDF4 output.
- force_v4
Logical. If `TRUE`, force creation of a netCDF4 output file.
- ...
Named bounds for dimensions to subset. Each argument name must match a dimension name. Values should be numeric vectors of length two giving lower and upper bounds. A length-one value is treated as an exact coordinate and expanded internally to `c(x, x)`.
- ignore.case
Logical. If `TRUE`, ignore case when matching dimension names supplied in `...`.
- drop
Logical. If `TRUE`, drop dimensions of length one in the output.
Value
Invisibly returns `output`, or `NULL` invisibly if none of the supplied dimension names match the variable dimensions.