I have a polyline layer and a points layer with features that are nearby the polylines. For the latter I want to find the closest points on the polylines (as existing vertices or new-created vertices along the polylines).

My initial approach is to loop through all polylines and check if their bounding boxes with a bit of buffer are intersecting the given points, so 2 for-loops then for each polyline candidate to loop through vertices and apply the distance point-line algorithm to find the closest point. But can become very slow especially for large datasets.

I've quickly checked Quadtrees but I see they are optimized for storing and fast lookup of point features. Is there anything similar for polylines or rectangles (bounding boxes)?

Later edit: I'm more interested in the algorithm / ways to store data because it's part of the software that I am implementing at this moment. So any existing GIS software / plugins examples are ok but I want to see what's "under the hood".

  • 2
    You have neglected to mention which GIS software you want to do this in?
    – Hornbydd
    Commented Dec 27, 2019 at 0:36
  • I've edited my post, is actually part of the software that I am writing so I want to understand the mechanics behind the existing GIS tools out there.
    – Fred
    Commented Dec 27, 2019 at 8:28
  • On such tool is Turf.js, see github.com/Turfjs/turf.
    – TomazicM
    Commented Dec 27, 2019 at 12:25

1 Answer 1


The question is a bit vague, but if you are using ArcGIS, you will most likely want to use proximity analysis (https://desktop.arcgis.com/en/arcmap/10.3/analyze/commonly-used-tools/proximity-analysis.htm).

This chart shows the different combinations of geometry for these operations with the one you described circled in yellow. (https://pro.arcgis.com/en/pro-app/tool-reference/analysis/how-near-analysis-works.htm)


In QGIS, there is a plugin called "NNjoin" that does something similar (https://plugins.qgis.org/plugins/NNJoin/)

Once you have the distances for all of your points, you can filter them accordingly.

  • Thanks for the answer, I'm actually need the solution to implement it in a software that I am writing. The ESRI tool is nice but I guess I cant see the source code, I'll have a look at the NNJoin plugin instead, thanks!
    – Fred
    Commented Dec 27, 2019 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.