st_contiguity: Identify polygon neighbors

View source: R/neighbors.R

st_contiguityR 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 TRUE. For more see ?spdep::poly2nb

...

additional arguments passed to spdep::poly2nb()

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)
 }

JosiahParry/sfdep documentation built on Sept. 7, 2024, 6:15 a.m.