[GIS] Drawing lines between points in QGIS

pointpoints-to-linepolyline-creationqgis

I am doing a research project for which I need to find an effective way for drawing lines between a number of points along a square. I need there to be a line between every point on the square in order to simulate the ability to cross the square whichever way a pedestrian pleases.

enter image description here

Ideally the process should generate a new line layer.

The end result needs to look something like this:

enter image description here

I have taken a look at previous posts on the subject, however the plugins that they recommend – PointsToPaths, Points2One – don't seem to be available in QGIS anymore, and the Points2One one doesn't work.

Best Answer

One way to do this would be using a "Virtual Layer".

  1. Create "X" and "Y" fields in your point layer containing the x and y coordinates
  2. Create a constant field with the same value
  3. Save a copy of the point layer
  4. Add a virtual layer joining by the constant value of both layers (original and copy) using the following expression:
SELECT *
FROM points
JOIN points_copy
    ON points.constant = points_copy.constant

This will create a Virtual Layer that will contain every combination of X,Y origin and destination coordinates. In my example I used 29 points thus resulting in a virtual layer of 841 points (29²).

All points to all

Just for symbolization purposes the point layer can be symbolized into lines using a geometry generator expression:

make_line(make_point("cx", "cy"), make_point("cx:1", "cy:1"))

To make a permanent layer I recommend using the tool XY to line from the plugin Shape Tools.