Functions to convert rmf_array and rmf_list objects to raster objects

rmf_as_raster(...)

# S3 method for rmf_2d_array
rmf_as_raster(array, dis, prj = rmf_get_prj(dis), ...)

# S3 method for rmf_3d_array
rmf_as_raster(array, dis, prj = rmf_get_prj(dis), ...)

# S3 method for rmf_4d_array
rmf_as_raster(array, dis, l = NULL, prj = rmf_get_prj(dis), ...)

# S3 method for rmf_list
rmf_as_raster(obj, dis, select, prj = rmf_get_prj(dis), ...)

Arguments

...

additional arguments passed to rmf_as_stars

array

rmf_2d_array, rmf_3d_array or rmf_4d_array object

dis

RMODFLOW dis object

prj

RMODFLOW prj object

l

integer specifying which dimension of a 4d array to convert to raster.

obj

rmf_list object

select

integer or character specifying which column of the rmf_list object to convert to raster object variable.

Value

an object of class RasterLayer if array is 2d, or RasterBrick when array is 3d or 4d with the bands representing the MODFLOW layers. The variable values are obtained from the array or from the select column for rmf_list objects.

Details

the objects are first converted to stars using rmf_as_stars. Conversions to raster objects will fail when arrays are rectilinear or rotated.

See also

Examples

dis <- rmf_create_dis() # 2d array r <- rmf_create_array(1:prod(dis$nrow, dis$ncol), dim = c(dis$nrow, dis$ncol)) rmf_as_raster(r, dis = dis)
#> class : RasterBrick #> dimensions : 10, 10, 100, 2 (nrow, ncol, ncell, nlayers) #> resolution : 100, 100 (x, y) #> extent : 0, 1000, 0, 1000 (xmin, xmax, ymin, ymax) #> crs : NA #> source : memory #> names : value, id #> min values : 1, 1 #> max values : 100, 100 #>
# 3d array r <- rmf_create_array(1:prod(dis$nrow, dis$ncol, dis$nlay), dim = c(dis$nrow, dis$ncol, dis$nlay)) rmf_as_raster(r, dis = dis, id = 'modflow')
#> class : RasterBrick #> dimensions : 10, 10, 100, 3 (nrow, ncol, ncell, nlayers) #> resolution : 100, 100 (x, y) #> extent : 0, 1000, 0, 1000 (xmin, xmax, ymin, ymax) #> crs : NA #> source : memory #> names : layer_1, layer_2, layer_3 #> min values : 1, 101, 201 #> max values : 100, 200, 300 #>
# 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_raster(r, dis = dis, l = 2)
#> class : RasterBrick #> dimensions : 10, 10, 100, 3 (nrow, ncol, ncell, nlayers) #> resolution : 100, 100 (x, y) #> extent : 0, 1000, 0, 1000 (xmin, xmax, ymin, ymax) #> crs : NA #> source : memory #> names : layer_1, layer_2, layer_3 #> min values : 301, 401, 501 #> max values : 400, 500, 600 #>
# rmf_list l <- rmf_create_list(data.frame(i = 1, j = 1:2, k = c(2, 2), q = c(-500, -400), d = 35)) rmf_as_raster(l, dis = dis, select = 'q')
#> class : RasterBrick #> dimensions : 10, 10, 100, 2 (nrow, ncol, ncell, nlayers) #> resolution : 100, 100 (x, y) #> extent : 0, 1000, 0, 1000 (xmin, xmax, ymin, ymax) #> crs : NA #> source : memory #> names : value, id #> min values : -500, 1 #> max values : 0, 100 #>
# rotated grids can not be converted to raster if (FALSE) { prj <- rmf_create_prj(rotation = 12) rmf_as_raster(r, dis = dis, l = 2, prj = prj) }