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

sfdep documentation built on Sept. 13, 2024, 5:07 p.m.