rmf_as_array.sf: Convert a simple features object to a rmf_array (rasterize)

View source: R/spatial.R

rmf_as_array.sfR Documentation

Convert a simple features object to a rmf_array (rasterize)

Description

Convert a simple features object to a rmf_array (rasterize)

Usage

## S3 method for class 'sf'
rmf_as_array(
  obj,
  dis,
  select,
  na_value = 0,
  prj = rmf_get_prj(dis),
  sparse = TRUE,
  kper = attr(obj, "kper"),
  ...
)

Arguments

obj

sf object

dis

RMODFLOW dis object

select

integer or character specifying which column from obj to rasterize

na_value

value of the cells in the array which are not specified in obj; defaults to 0

prj

RMODFLOw prj object

sparse

logical; should a 2d (TRUE; default) or 3d (FALSE) array be returned

kper

optional integers specifying the stress-periods during which this array is active

...

additional arguments passed to stars::st_rasterize

Details

stars::st_rasterize is used to rasterize obj to the MODFLOW grid which calls GDALRasterize. Alternatively, the user can call rmf_as_list on obj and rmf_as_array on the resulting rmf_list. Results may differ.

Value

a rmf_2d_array if sparse = TRUE; a rmf_3d_array if sparse = FALSE

Examples

sfc <- sf::st_sfc(list(sf::st_point(c(100,200)), sf::st_point(c(750, 800)), sf::st_point(c(700, 850))))
obj <- sf::st_sf(q = c(-500, -400, -300), geom = sfc)
dis <- rmf_create_dis()
rmf_as_array(obj, dis = dis, select = 'q')
rmf_as_array(obj, dis = dis, select = 'q', options = c('MERGE_ALG=ADD'))

# alternative
rmf_as_list(obj, dis = dis, select = 'q') %>%
  rmf_as_array(dis = dis)

rogiersbart/RMODFLOW documentation built on Jan. 14, 2023, 4:21 a.m.