spdep_contiguity_swm {sdsfun} | R Documentation |
constructs spatial weight matrices based on contiguity
Description
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. |
queen |
(optional) if |
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 |
cumulate |
(optional) Whether to accumulate adjacency objects. Default is |
style |
(optional) |
zero.policy |
(optional) if |
Value
A matrix
Note
When k
is set to a positive value, using K-Nearest Neighbor Weights.
Examples
library(sf)
pts = read_sf(system.file('extdata/pts.gpkg',package = 'sdsfun'))
wt1 = spdep_contiguity_swm(pts, k = 6, style = 'B')
wt2 = spdep_contiguity_swm(pts, queen = TRUE, style = 'B')
wt3 = spdep_contiguity_swm(pts, queen = FALSE, order = 2, style = 'B')