Given a point pattern and a line segment pattern, this function finds the nearest line segment for each point.
A point pattern (object of class
A line segment pattern (object of class
The distance between a point
x and a straight line segment
defined to be the shortest Euclidean distance between
x and any
y. This algorithm first calculates the distance
from each point of
each segment of
Y. Then it determines, for each point
X, which segment of
Y is closest. The index of this
segment is returned.
v (of length equal to the number of points in
X) identifying the nearest segment to each point.
v[i] = j, then
Y[j] is the line segment lying closest to
identify the nearest line segment for each pixel in a grid.
1 2 3 4 5 6 7