Identify geometries that are near to each other. Either get the index of all geometries within a certain distance, or the k nearest neighbors, or (with nearest) get the nearest points between two geometries.
# S4 method for SpatVector
nearest(x, y, pairs=FALSE, centroids=TRUE, lines=FALSE)
Value
matrix
Arguments
x
SpatVector
y
SpatVector or NULL
distance
numeric. maximum distance
k
positive integer. number of neighbors. Ignored if distance > 0
centroids
logical. Should the centroids of polygons be used?
symmetrical
logical. If TRUE, a near pair is only included once. That is, if geometry 1 is near to geometry 3, the implied nearness between 3 and 1 is not reported. Ignored if k neighbors are returned
pairs
logical. If TRUE pairwise nearest points are returned (only relevant when using at least one SpatVector of lines or polygons
lines
logical. If TRUE lines between the nearest points instead of (the nearest) points