st_knn | R Documentation |
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.
st_knn(geometry, k = 1, symmetric = FALSE, ...)
geometry |
an sf or sfc object. |
k |
number of nearest neighbours to be returned |
symmetric |
default |
... |
additional arguments to be passed to |
This function utilizes spdep::knearneigh()
and spdep::knn2nb()
.
a list of class nb
Other neighbors:
st_contiguity()
,
st_dist_band()
st_knn(sf::st_geometry(guerry), k = 8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.