
constructs spatial weight matrices based on contiguity
Source:R/spdep_helpers.R
spdep_contiguity_swm.RdConstructs 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
sfobject or can be converted tosfbysf::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)
stylecan take valuesW,B,C, andS. More to seespdep::nb2mat(). Default isW.- zero.policy
(optional) if
FALSEstop with error for any empty neighbour sets, ifTRUEpermit 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')