| rmf_interpolate | R Documentation |
Interpolation of points on a rmf_2d/3d/4d_array
rmf_interpolate(...) ## S3 method for class 'rmf_2d_array' rmf_interpolate( array, dis, xout, yout, obj = NULL, method = "linear", outside = "nearest", prj = rmf_get_prj(dis), mask = array * 0 + 1 ) ## S3 method for class 'rmf_3d_array' rmf_interpolate( array, dis, xout, yout, zout, obj = NULL, method = "linear", outside = "nearest", prj = rmf_get_prj(dis), mask = array * 0 + 1 ) ## S3 method for class 'rmf_4d_array' rmf_interpolate( array, dis, xout, yout, zout, tout, obj = NULL, method = "linear", outside = "nearest", time = "step", prj = rmf_get_prj(dis), mask = array(1, dim = dim(array)[1:3]) )
array |
numeric rmf_2d/3d/4d_array |
dis |
|
xout |
x coordinates of points to interpolate to |
yout |
y coordinates of points to interpolate to |
obj |
sf or sfc point or multipoint object to obtain the point locations from. Overrides |
method |
interpolation method. Possible methods are 'nearest' for nearest-neighbor or 'linear' (default) for bi/trilinear interpolation. |
outside |
'nearest' or 'drop'. Defines how interpolated points outside the convex hull described by the cell nodes should be handled for method = 'linear'. 'nearest' (default) sets the values equal to the nearest nodal value, 'drop' sets them to NA. |
prj |
|
mask |
a 2d array when |
zout |
z coordinates of points to interpolate to when the array is 3d or 4d. |
tout |
time instances to interpolate to when the array is 4d. Either as a fractional time step or as total simulated time, depending on the |
time |
either 'step' (default) or 'totim'. Defines if |
Users must make sure that the projection of xout, yout, zout or obj are the same as the one described by the prj argument.
Function assumes the 2d array is not a cross-section. Consider using a 3d array if the vertical dimension is of any concern.
Extrapolation is not supported: values outside the grid are set to NA. Values inside the grid but outside the convex hull described by the cell nodes depend on the 'outside' argument when method = 'linear'.
Interpolation of a point on a 4d array is performed by 3d interpolation at the nearest time steps followed by a interpolation of the obtained values using the specified method.
a vector with the interpolated values for each point.
dis <- rmf_create_dis() n <- 50 xout <- runif(n, min = -10, max = 1010) yout <- runif(n, min = -10, max = 1010) zout <- runif(n, min = -31, max = 1) # 2d array <- rmf_create_array(1:prod(dis$nrow, dis$ncol), dim = c(dis$nrow, dis$ncol)) rmf_interpolate(array, dis, xout, yout) rmf_interpolate(array, dis, xout, yout, outside = 'drop') rmf_interpolate(array, dis, xout, yout, method = 'nearest') # 3d array <- rmf_create_array(1:prod(dis$nrow, dis$ncol, dis$nlay), dim = c(dis$nrow, dis$ncol, dis$nlay)) rmf_interpolate(array, dis, xout, yout, zout, outside = 'drop') pts <- sf::st_sfc(list(sf::st_point(c(150, 312, -12.5)), sf::st_point(c(500, 500, -22)), sf::st_point(c(850, 566, -16.3)))) rmf_interpolate(array, dis, obj = pts) # 4d array <- rmf_create_array(1:prod(dis$nrow, dis$ncol, dis$nlay, 4), dim = c(dis$nrow, dis$ncol, dis$nlay, 4)) attr(array, 'totim') <- c(100, 200, 500, 780) tout <- runif(n, min = 0.85, max = 4.2) # tout as fractional time step rmf_interpolate(array, dis, xout, yout, zout, tout) tout <- runif(n, min = 90, max = 800) # tout as total time rmf_interpolate(array, dis, xout, yout, zout, tout, time = 'totim')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.