powered by
construct neighbours list
spdep_nb(sfj, queen = TRUE, k = NULL, order = 1L, cumulate = TRUE)
A neighbours list with class nb
nb
An sf object or can be converted to sf by sf::st_as_sf().
sf
sf::st_as_sf()
(optional) if TRUE, using queen contiguity, otherwise rook contiguity. Default is TRUE.
TRUE
(optional) The number of nearest neighbours. Ignore this parameter when not using distance based neighbours.
(optional) The order of the adjacency object. Default is 1.
1
(optional) Whether to accumulate adjacency objects. Default is TRUE.
pts = sf::read_sf(system.file('extdata/pts.gpkg',package = 'sdsfun')) nb1 = spdep_nb(pts, k = 6) nb2 = spdep_nb(pts, queen = TRUE) nb3 = spdep_nb(pts, queen = FALSE, order = 2)
Run the code above in your browser using DataLab