nearest | R Documentation |
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 signature 'SpatVector'
nearby(x, y=NULL, distance=0, k=1, centroids=TRUE, symmetrical=TRUE, method="geo")
## S4 method for signature 'SpatVector'
nearest(x, y, pairs=FALSE, centroids=TRUE, lines=FALSE, method="geo")
x |
SpatVector |
y |
SpatVector or NULL |
distance |
numeric. maximum distance |
k |
positive integer. number of neighbors. Ignored if |
centroids |
logical. Should the centroids of polygons be used? |
symmetrical |
logical. If |
method |
character. One of "geo", "haversine", "cosine". With "geo" the most precise but slower method of Karney (2003) is used. The other two methods are faster but less precise |
pairs |
logical. If |
lines |
logical. If |
matrix
distance
, relate
, adjacent
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
nearby(v, distance=12000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.