3

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.

  • First you have to determine the order in which the points should be connected. – Vincent Bré Feb 19 at 7:33
2

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.

| improve this answer | |
1

In QGIS you can make use of the virtual layers.

Go to Layer/ Add layer/ add-edit virtual layer and enter the following query. Feel free to add as many field as you want. The trick is to do a cross-join on the same table, generating every combination between the two layers.

select a.id, b.id, makeline(a.geometry, b.geometry) as geometry
from myLayer a, myLayer b
where a.id <> b.id
| improve this answer | |

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.