[GIS] How to select points within a certain distance from a line

pointpolygon-creationqgis-2.10qgis-pluginsselect-by-location

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

Best Answer

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!