RANN
RANN copied to clipboard
points to line distance
Hi, thanks for the nn2 function, it has transformed the efficiency of distance calculations for large datasets. I have a related problem, where I would like to calculate the distance from each point to the closest point on a line. I can convert the line to a set of coordinates and then run nn2, however, this is sort of cheating as it doesn't formally calculate distance to the line that connects each of those coordinates. I just wondered whether you were working on (or could be persuaded to! :)) a function to do this? At the moment dist2line from geosphere is the best option I have, but it is very slow, even if parallelized, on large datasets. I'm working on a function to first find the nearest line, then sample points along that line and run nn2, but its pretty inelegant...
Thanks again!