read_r2c_raster: Reads r2c file to raster brick

Description Usage Arguments Value Author(s) See Also Examples

View source: R/read_r2c_raster.R

Description

This function reads a file containing a time series of 2D values, which is output from a MESH model. It is not intended to read in a file describing a drainage basin. For that purpose, you should be using the function read_r2c_shed. This function returns eiher a raster brick or an rts rts object, which is a timeseries raster. Each Frame in the original file becomes a separate layer. 'The name of each layer in the raster brick is set to the time stamp of each Frame. Because the layer names are standard R variables, they must obey the rules for variable names, inclusing beginning with a character, and not containing spaces. These rule will change the layer names if you are not careful.

Usage

1
2
3
4
5
6
7
read_r2c_raster(
  r2cFile,
  NAvalue = NULL,
  as_rts = FALSE,
  timezone = "",
  layerNameFormat = NULL
)

Arguments

r2cFile

Required. Name of r2c file containing time series.

NAvalue

Optional. If specified, values smaller than NAvalue will be set to NA_real_

as_rts

Optional. If TRUE, the returned value will be a rts object, which allows the creation of 1-D time series, and for temporal aggregation. If FALSE (the default) a standard raster brick object is returned, which is better for simple plotting of the layers.

timezone

Optional. If the r2cFile contains date values for each Frame, then the Frame times are returned as R dates. If there are hours and seconds, then they will be converted to POSIXct datetime values. In this case, you may want to specify the timezone of the data. If the timezone is not specified, your default value will be used.

layerNameFormat

Optional. Sets the layer names when returning the raster brick to avoid conflicting with the R variable rules.

Value

Returns eiher a raster brick or an rts rts object.

Author(s)

Kevin Shook

See Also

rts read_r2c_shed

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
temps <- read_r2c_raster("TA_M.r2c", NAvalue = 0, as_rts = FALSE, layerNameFormat = "%b_%Y")
# convert air temps from K to C
temps <- temps - 273.15
plot(temps)
# create an animation and save it as a file
library(animation)
saveGIF(animate(temps, n = 1))
## End(Not run)

CentreForHydrology/MESHr documentation built on Jan. 11, 2021, 8:34 p.m.