constructs spatial weight matrices based on contiguity
Source:R/spdep_helpers.R
spdep_contiguity_swm.Rd
Constructs spatial weight matrices based on contiguity via spdep
package.
Usage
spdep_contiguity_swm(
sfj,
queen = TRUE,
k = NULL,
order = 1L,
cumulate = TRUE,
style = "W",
zero.policy = TRUE
)
Arguments
- sfj
An
sf
object or can be converted tosf
bysf::st_as_sf()
.- queen
(optional) if
TRUE
, using queen contiguity, otherwise rook contiguity. Default isTRUE
.- k
(optional) The number of nearest neighbours. Ignore this parameter when not using distance based neighbours to construct spatial weight matrices.
- order
(optional) The order of the adjacency object. Default is
1
.- cumulate
(optional) Whether to accumulate adjacency objects. Default is
TRUE
.- style
(optional)
style
can take valuesW
,B
,C
, andS
. More to seespdep::nb2mat()
. Default isW
.- zero.policy
(optional) if
FALSE
stop with error for any empty neighbour sets, ifTRUE
permit the weights list to be formed with zero-length weights vectors. Default isTRUE
.
Examples
gzma = sf::read_sf(system.file('extdata/gzma.gpkg',package = 'sdsfun'))
wt1 = spdep_contiguity_swm(gzma, k = 6, style = 'B')
wt2 = spdep_contiguity_swm(gzma, queen = TRUE, style = 'B')
wt3 = spdep_contiguity_swm(gzma, queen = FALSE, order = 2, style = 'B')