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?

Taras
  • 32,823
  • 4
  • 66
  • 137
DGIS
  • 2,527
  • 16
  • 36
  • What ArcGIS took did you use to do that and was it from ArcGIS Pro or from ArcMap? – PolyGeo Feb 21 '22 at 22:16
  • Also pay attention to these related threads: [1] https://gis.stackexchange.com/questions/141078/generating-line-segments-between-all-points-using-qgis [2] https://gis.stackexchange.com/questions/366235/creating-all-possible-line-segments-between-all-points-using-qgis – Taras Feb 22 '22 at 07:19

1 Answers1

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

Taras
  • 32,823
  • 4
  • 66
  • 137
JGH
  • 41,794
  • 3
  • 43
  • 89
  • When I try this the geometry field is null on a shapefile and a geopackage; should this still work for QGIS3? – MrKingsley Nov 03 '23 at 11:49
  • 1
    @MrKingsley yes, it is still working. Make sure your layer is point, not multipoint – JGH Nov 03 '23 at 12:05