Transforming a sf into a spm object (Internal use)
Usage
single_sf_to_spm(
sf_obj,
n_pts,
type = "regular",
by_polygon = FALSE,
poly_ids = NULL,
var_ids = NULL
)
sf_to_spm(
sf_obj,
n_pts,
type = "regular",
by_polygon = FALSE,
poly_ids = NULL,
var_ids = NULL
)Arguments
- sf_obj
a
sfobject s.t. its geometries are polygons.- n_pts
a
numericscalar representing the number of points to create a grid in the study region on which the polygons insf_objis observed. Alternatively, it can be a vector of the same length asnrow(sf_obj). In this case, it generates the given number of points for each polygon insf_obj.- type
a
characterindicating the type of grid to be generated. The options arec("random", "regular", "hexagonal"). For more details, seest_samplein thesfpackage.- by_polygon
a
logicalindicating whether we should generaten_ptsby polygon or for then_ptsfor the whole study region.- poly_ids
a
charactervector informing the name of the variable insf_objthat represents the polygons unique identifiers. In case this is not informed, we assume the id of the polygons are given by their row numbers.- var_ids
a scalar or vector of type
characterindicating the (numerical) variables that are going to be analyzed.
Value
a named list of size 6 belonging to the class
spm. This list stores all the objects necessary to fit models
using the fit_spm.
Examples
data(liv_lsoa) # loading the LSOA data
msoa_spm <- sf_to_spm(sf_obj = liv_msoa, n_pts = 1000,
type = "regular", by_polygon = FALSE,
poly_ids = "msoa11cd",
var_ids = "leb_est")
