add_neighbour {bigDM} | R Documentation |
The function returns a neighbour list of class nb
and its associated spatial adjacency matrix
computed by adding isolated areas to its nearest neighbour (in terms of Euclidean distance between centroids) using the knearneigh
function of 'spdep' package.
add_neighbour(carto, nb = NULL, plot = FALSE)
carto |
object of class |
nb |
optional argument with the neighbour list of class |
plot |
logical value (default |
This function returns a list with the following two elements:
nb
: the modified neighbours's list
W
: associated spatial adjacency matrix of class CsparseMatrix
library(spdep)
## Load the Spanish colorectal cancer mortality data ##
data(Carto_SpainMUN)
## Compute the neighbour list from spatial polygons ##
nb_SpainMUN <- poly2nb(Carto_SpainMUN)
summary(nb_SpainMUN) # 1 region with no links
## Add isolated area to its nearest neighbour ####
carto.mod <- add_neighbour(carto=Carto_SpainMUN, nb=nb_SpainMUN)
summary(carto.mod$nb) # 0 region with no links