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,
trunc_d = NULL
)
sf_to_spm(
sf_obj,
n_pts,
type = "regular",
by_polygon = FALSE,
poly_ids = NULL,
var_ids = NULL,
trunc_d = NULL
)
Arguments
- sf_obj
a
sf
object s.t. its geometries are polygons.- n_pts
a
numeric
scalar representing the number of points to create a grid in the study region on which the polygons insf_obj
is 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
character
indicating the type of grid to be generated. The options arec("random", "regular", "hexagonal")
. For more details, seest_sample
in thesf
package.- by_polygon
a
logical
indicating whether we should generaten_pts
by polygon or for then_pts
for the whole study region.- poly_ids
a
character
vector informing the name of the variable insf_obj
that 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
character
indicating the (numerical) variables that are going to be analyzed.- trunc_d
truncation distance for grid points. Consider using half of the maximum distance between polygons
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")