st_contiguity | R Documentation |
Given an sf geometry of type POLYGON
or MULTIPOLYGON
identify contiguity based neighbors.
st_contiguity(geometry, queen = TRUE, ...)
geometry |
an sf or sfc object. |
queen |
default |
... |
additional arguments passed to |
Utilizes spdep::poly2nb()
a list of class nb
Other neighbors:
st_dist_band()
,
st_knn()
# on basic polygons
geo <- sf::st_geometry(guerry)
st_contiguity(geo)
if (requireNamespace("dplyr", quietyl = TRUE)) {
# in a pipe
library(magrittr)
guerry %>%
dplyr::mutate(nb = st_contiguity(geometry), .before = 1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.