nc_grid_to_dt_raw {eurocordexr} | R Documentation |
Convert a netcdf array to long format as data.table (raw version)
Description
Extracts a variable from netcdf, similar to nc_grid_to_dt
, but
in a raw version. Requires more manual info, does not convert time units
(like 'days since x'), and requires xy variables not dimensions (like a
curvilinear grid).
Usage
nc_grid_to_dt_raw(
filename,
variable,
var_t,
var_x,
var_y,
has_time = TRUE,
icell_raster_pkg = TRUE
)
Arguments
filename |
Complete path to .nc file. |
variable |
Character, name of the variable to extract (required). |
var_t |
Character, name of the time variable. (recommended if has_time=TRUE) |
var_x |
(optional) Character, name of the x coordinate variable (not dimension!). If both var_x and var_y are supplied, results will have xy columns, too. |
var_y |
(optional) Character, name of the y coordinate variable (not dimension!). If both var_x and var_y are supplied, results will have xy columns, too. |
has_time |
Boolean, if |
icell_raster_pkg |
Boolean, if |
Details
Names of netcdf variables can be inquired in a terminal with "ncdump -h", or
in R for example using ncdf4::nc_open(filename)
.
Example use cases: netcdf file has issues with dimensions (no dimvar), time variable is in non-standard format.
Value
A data.table
with columns icell (cell
index), time (if has_time=T), value. Only if var_x and var_y supplied also
x and y. Column names except icell are variable names as in the netcdf
file.
See Also
Examples
# example data
fn3 <- system.file("extdata", "test3.nc", package = "eurocordexr")
dat <- nc_grid_to_dt_raw(fn3, "tasmax", "Times")
str(dat)