Learn R Programming

RSurvey (version 0.8-3)

ProcessData: Process Data

Description

This function performs data processing on the state variables.

Usage

ProcessData(d, type = "p", coerce.rows = NULL, ply = NULL, grid.res = list(x = NA, y = NA), grid.mba = list(n = NA, m = NA, h = 11))

Arguments

d
data.frame; the data to be processed, a table with variables x, y, z, t, vx, vy, and vz.
type
character; a 1-character string giving the resulting output type. The following values are possible: "p" for points and "g" for interpolated grid.
coerce.rows
logical; a vector indicating rows in d to include in the processed data set. NA
ply
gpc.poly; if type = "p" a polygon that defines either the data limits, else if type = "g" a crop region for gridded data.
grid.res
list; numeric components giving the grid spacing along the x- and y-axis for interpolated values, see SetInterpolation.
grid.mba
list; integer components giving the input parameters for the multilevel B-splines algorithm, see SetInterpolation.

Value

If type = "p" returns a data frame with variables:
x, y
numeric; a vector of x and y coordinates.
z
numeric; a vector of state variable values (optional).
vx, vy, vz
numeric; a vector of velocity components in the x, y and z directions, respectively (optional).
If type = "g" returns a list with components:
x, y
numeric; a vector of grid line locations at which the values in z are measured.
z
matrix; interpolated surface of state variable with rows and columns corresponding to grid lines in the x and y directions, respectively.
vx, vy, vz
matrix; interpolated surface of velocity components with rows and columns corresponding to grid lines in the x and y directions (optional).
vf
numeric; volumetric flux (optional).

Details

Any row in the d data table with NA values for either x or y is removed. Rows are also removed where coerce.rows is FALSE. The spatial domain may be limited using a polygon defined in the xy-plane. Interpolated grid values corresponding to grid nodes located outside the polygon boundary are set to NA.

See Also

point.in.polygon, CutoutPolygon, mba.points

Examples

Run this code
x <- c(7.8, 5, 2.2, 3.7, NA, -1.6, -7.5)
y <- c(-2.3, -4.7, -2.2, -2.3, -3.4, -1.6, -7.5)
z <- c(-0.9, -1.2, -2.4, -2.4, -0.4, 0.1, 2)
t <- c("4/23/2009 10:43", "4/24/2009 11:20", "4/24/2009 12:08", "4/24/2009 12:50",
       "4/24/2009 13:51", "4/24/2009 14:24", "4/24/2009 14:44")
t <- as.POSIXct(t, format = "%m/%d/%Y %H:%M")

data.raw <- as.data.frame(list(x = x, y = y, z = z, t = t))
data.pts <- ProcessData(data.raw, type = "p")
data.grd <- ProcessData(data.pts, type = "g")

ply <- as(cbind(c(-4, 2, -6), c(-7, -3, -3)), "gpc.poly")
grid.res <- list(x = 0.2, y = 0.5)
data.grd <- ProcessData(data.pts, type = "g", ply = ply, grid.res = grid.res)

Run the code above in your browser using DataLab