4

I have a point layer and I'm Looking for a tool which connects every point of the layer with each other. Ideally, I can give a distance and the number of Connections for each point.

The following example is from the ArcGIS tool
enter image description here

In the example each point connects to nine other points which are within distance X Meters.

Is there a tool like that in QGIS or a Plugin or can it be done with the Geometry Generator somehow?

2

1 Answer 1

10

Using the distance, you could create a "Virtual Layer" that connects nearby points.

Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the following query.

Note that the line is created once between 2 points (A-B is the same as B-A).

SELECT
    make_line(a.geometry, b.geometry) as geometry,
    a.id as fromID,
    b.id as toID
FROM
    myPointLayer a
JOIN
    myPointLayer b
    ON ST_Distance(a.geometry, b.geometry) < 5000
    AND a.id < b.id

enter image description here

2
  • When I try this the geometry field is null on a shapefile and a geopackage; should this still work for QGIS3?
    – MrKingsley
    Nov 3 at 11:49
  • 1
    @MrKingsley yes, it is still working. Make sure your layer is point, not multipoint
    – JGH
    Nov 3 at 12:05

Your Answer

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

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