View source: R/conversion_functions.R
ncdf2raster | R Documentation |
This function imports netCDF files to R 'RasterLayer','RasterStack', and 'data.frame'.
ncdf2raster( pth, flip = NULL, transpose = FALSE, time = NULL, origin = "1901-01-01", spatial = NULL, varName = NULL, fun = NULL, temporal_fun = NULL, crs = "+init=EPSG:4326", ... )
pth |
a path to a NetCDF file with the extension |
flip |
|
transpose |
|
time |
If not set to |
origin |
temporal origin of the input NetCDF, defaults to |
spatial |
If not set to |
varName |
If not set to |
fun |
function for spatial summarize. |
temporal_fun |
|
crs |
proj4 string input to |
... |
additional arguments to function provided to the |
attrs |
|
The function can imports 2 or 3-dimensional single/multi-variable NetCDF files into R. It provides users with temporal and spatial subset and summary options.
The spatial
argument accepts a point coordinate data.frame (x, y) or a RasterLayer
mask as input. If points are provided, the function
returns a data.frame with the value for each point, time, and variable. A RasterLayer
input return the masked map by default. The user
can use a weight RasterLayer
as a spatial mask, so the result is the multiplication of the values by the weights.
The time
argument accepts one or two (from, to) points in time as a numeric
/integer
index or as Date
. In the former case, the i to j th
time points are being extracted from the file. When Date
is provided it is first being converted to days since the defined origin
, which is
later searched within the values of the file's time dimension. origin
should fit units defined in the file's time dimension.
Summarizing the result can be applied spatially with the fun
and ...
argument, or temporally with the temporal_fun
argument.
Temporal summary applies pre-defined statistical transformation (e.g., sum, mean, sd, and cv, coefficient of variance) to every grid-cell on the x-y plane across time points,
thus it converts 3 dimensional array to 2 dimensional.
Spatial summary applies user defined statistical transformation (e.g., sum, mean, sd) to every time point, resulting in a data.frame
with the
var, time, and summarized value.
The user can apply both summaries at the same time.
a data.frame
, a RasterLayer
, a RasterStack
, or a named list
## Not run: PUT EXAMPLE HERE ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.