Learn R Programming

terra (version 1.0-10)

near: nearby geometries

Description

Identify geometries that are near to each other. Either get the index of all geometries within a cetain distance, or get the k nearest neighbors.

Usage

# S4 method for SpatVector
near(x, distance=0, k=1, centroids=TRUE, symmetrical=TRUE, ...)

Arguments

x

SpatVector

distance

numeric. maximum distance

k

postive integer. number of neighbors. Ignored of 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

...

additional arguments. None implemented

Value

matrix

See Also

relate, adjacent

Examples

Run this code
# NOT RUN {
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
near(v, distance=12000)
# }

Run the code above in your browser using DataLab