I have a file with a points layer and a lines layer. I would like to select only the points that lay within certain distance (a couple of meters) of the lines.

Is there an easy way to do this?

Or should I create a new polygone layer wich forms a kind of buffer around te lines and then use the select bij location tool?

How can I create such a layer?

enter image description here


I am not sure if you are using ArcGIS or not but if you are and I dont know if this is the most ideal answer but yes, run the buffer tool and create a buffer around your line at whatever distance you want. Then run the select by spatial location and select all points that are completely contained by the newly created buffer layer. This will give you the answer you are looking for


I strongly suggest the method mentioned by yourself and @user3338197 as it's probably the simplest.

Another method to calculate the distance from a point to its nearest line involves first having to convert your line layer to points using Convert lines to points from SAGA (in the Processing Toolbox). Select Yes for the Insert Additional Points option and use a very low value for the Insert Distance (such as 0.01, note that this is measured in metres). This adds a point every 0.01 m so the lower this value is, the more accurate you will be when finding the nearest distance.

Now you can use the Distance to nearest hub tool which calculates the distance (in metres, feet, layer units etc.) from a source to the destination layer.

You will have the option of exporting another point shapefile which will have an attribute containing the distances of each point to its nearest line:

Distance to nearest hub

You can then use the Field Calculator or Select by expression tool to only show/select points within x metres:

"HubDist" < x

Hope this helps!

  • 1
    Heres an upvote for a new method i didnt know about!
    – ed.hank
    Sep 14 '15 at 14:40
  • @user3338197 - Haha thank you but it wasn't necessary! You learn something new everyday (I always do!). But I like your method as I have used it in the past and has always worked a treat =)
    – Joseph
    Sep 14 '15 at 14:50
  • 1
    Yup, one of the things I love about GIS is there is definitely more than one way to skin the cat!
    – ed.hank
    Sep 14 '15 at 14:57
  • Hello, thank you for your help but unfortunately I could not repeat all the steps you mentioned above. I have now created a distance to nearest hub layer, but I can not select the points within, say, 3 meters with the Field calculator. I have selected Hub Distance as input layer and gave the output field a name. And then in in the expression field I have typed: "HubDist" < 3. This way it selects all the points. But how do I select a unit, in this case meters? Also, I can not find the other method: Select by expression, where can I find this?
    – D. Sanders
    Sep 17 '15 at 9:00
  • 1
    Thank you very much, I started over the whole project from scratch, because not all layers where in the same crs, this was creating issues with the buffer method. Now that I sorted it out it worked perfect. Thank you both for your help Joseph and @user3338197, it is much appreciated! I learned a lot from it. Have a good day.
    – D. Sanders
    Sep 21 '15 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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