st_contiguity {sfdep} | R Documentation |
Identify polygon neighbors
Description
Given an sf geometry of type POLYGON
or MULTIPOLYGON
identify contiguity based neighbors.
Usage
st_contiguity(geometry, queen = TRUE, ...)
Arguments
geometry |
an sf or sfc object. |
queen |
default |
... |
additional arguments passed to |
Details
Utilizes spdep::poly2nb()
Value
a list of class nb
See Also
Other neighbors:
st_dist_band()
,
st_knn()
Examples
# 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)
}
[Package sfdep version 0.2.4 Index]