0

I am trying to figure out a way to connect every point in a data table with lines. To be specific I do not want to create a line path by consecutive points but rather, in a simplified version of my problem if there were 4 points in a table the vector creation would make six lines. Line1:p1-p2, Line2:p1-p3, Line3:p1-p4,Line4:p2-p4,Line5:p3-p4,Line6:p2-p3.

My problem is that I am dealing with over 1000 points, so attempting this manually is not practical. I was hoping that there potentially is a plugin that would perform this but I have not found anything yet.

1
  • See second solution provided to this question gis.stackexchange.com/questions/242524/… You can omit the lineid part which goes beyond your requirement. Just create the virtual layer, and save it if you need to.
    – Kasper
    Commented Sep 17 at 19:37

1 Answer 1

0

You can use SQL to create a "Virtual Layer" via Layer/ Add layer/ add-edit virtual layer:

select row_number() over() as new_id,
        a.id as a_id,
        b.id as b_id,
        setsrid(make_line(a.geometry, b.geometry), st_srid(a.geometry)) as geometry
from myPoints as a
cross join myPoints as b
where a.id < b.id

The query joins the layer to itself where ids are different, then creates a line between the joined points.

You need a unique id column, my is named id. Replace id in a.id and b.id with the name of your id column. And replace myPoints with your layer name.

enter image description here

3

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