I have 10 points in QGIS layer as shown in Image 1
.
I am trying to connect points with lines in required sequence as shown in
Image 2
. However, when I tried to connect all points with virtual layer, the connections are not according to my required sequence (yellow lines) as shown inImage 3
. What should I do to get the required connections?The features in attribute table are shown here. Do I need to change the IDs of points to achieve the required connections?
I was thinking about parent layer and child layer for required connections but I am not sure how to achieve that.
The shapfile is available here
Virtual layer query that I have tried (Image 3):
In this query, I am trying to connect points with line by saving the start and end points
of each connecting line.
with
build_segment as (
select
a.GlobalID as start_point,
b.GlobalID as end_point,
makeline(a.geometry, b.geometry) as geometry
from Points_Colac_Demo_advanced a
left join Points_Colac_Demo_advanced b on (a.OBJECTID + 1 = b.OBJECTID))
select
*
from build_segment
where geometry is not null
a.id = relationTable.FromID
andb.id = relationTable.ToId