Identifies the k nearest neighbors for given point geometry. If polygon geometry is provided, the centroids of the polygon will be used and a warning will be emitted.
Usage
st_knn(geometry, k = 1, symmetric = FALSE, ...)
Value
a list of class nb
Arguments
geometry
an sf or sfc object.
k
number of nearest neighbours to be returned
symmetric
default FALSE. Whether to force output of neighbours to be symmetric.
...
additional arguments to be passed to knearneigh().
Details
This function utilizes spdep::knearneigh() and spdep::knn2nb().