rmf_as_sf | R Documentation |
Functions to convert rmf_array and rmf_list objects to simple features
rmf_as_sf(...) ## S3 method for class 'rmf_2d_array' rmf_as_sf( array, dis, mask = array * 0 + 1, prj = rmf_get_prj(dis), name = "value", as_points = FALSE, id = "r", ... ) ## S3 method for class 'rmf_3d_array' rmf_as_sf( array, dis, mask = array * 0 + 1, prj = rmf_get_prj(dis), name = "value", as_points = FALSE, id = "r", ... ) ## S3 method for class 'rmf_4d_array' rmf_as_sf( array, dis, mask = array(1, dim = dim(array)[1:3]), prj = rmf_get_prj(dis), name = "value", as_points = FALSE, id = "r", ... ) ## S3 method for class 'rmf_list' rmf_as_sf(obj, dis, prj = rmf_get_prj(dis), as_points = FALSE, id = "r", ...)
... |
additional arguments passed to |
array |
|
dis |
|
mask |
a 2d array when |
prj |
|
name |
character specifying the name of the resulting variable in the sf object. Defaults to |
as_points |
logical; should returned sf object represent cell-centered nodal points (TRUE) or cell polygons (FALSE, default) |
id |
either |
obj |
|
The returned z coordinate when as_points = TRUE
reflects the cell node.
The crs is taken from the prj
argument.
Note that in MODFLOW, row indices (i) increase with decreasing Y coordinates, i.e. row 1 - column 1 corresponds to the upperleft cell.
A sf
object with point geometries representing the cell-centered nodes when as_points = TRUE
. When as_points = FALSE
,
the geometries are polygons representing the entire cell.
When converting a rmf_array
, the sf
object has following variables: one with the array values per cell/node,
one containing the cell id (when id
is 'r'
or 'modflow'
), top and bottom of the cells when the array is 3d or 4d plus the z value of the node when as_points = TRUE
.
When a 4d array is converted, an additional time column is added as well.
When converting a rmf_list
, all variables in the rmf_list
object are retained with the addition of the cell id column (when id
is 'r'
or 'modflow'
) and
top and bottom columns if as_points = FALSE
or a z column when as_points = TRUE
.
dis <- rmf_create_dis() # 2d array r <- rmf_create_array(1:prod(dis$nrow, dis$ncol), dim = c(dis$nrow, dis$ncol)) rmf_as_sf(r, dis = dis) rmf_as_sf(r, dis = dis, as_points = TRUE) # 3d array r <- rmf_create_array(1:prod(dis$nrow, dis$ncol, dis$nlay), dim = c(dis$nrow, dis$ncol, dis$nlay)) rmf_as_sf(r, dis = dis, id = 'modflow') rmf_as_sf(r, dis = dis, as_points = TRUE) # 4d array r <- rmf_create_array(1:prod(dis$nrow, dis$ncol, dis$nlay, 2), dim = c(dis$nrow, dis$ncol, dis$nlay, 2)) rmf_as_sf(r, dis = dis, id = FALSE) # rmf_list l <- rmf_create_list(data.frame(i = 1, j = 1:2, k = c(3, 2), q = c(-500, -400))) rmf_as_sf(l, dis = dis) # 2d array with varying cellsize dis$delr <- c(seq(50, 10, length.out = 7), seq(10, 50, length.out = 3)) dis$delc <- c(seq(100, 20, length.out = 7), seq(30, 100, length.out = 3)) # increasing i with decreasing Y r <- rmf_create_array(1:prod(dis$nrow, dis$ncol), dim = c(dis$nrow, dis$ncol)) rmf_as_sf(r, dis = dis)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.