TransWikia.com

Connecting points with lines and saving starting and ending points in new layer

Geographic Information Systems Asked by Case Msee on January 24, 2021

I have 3 points in one layer as shown in the first image. I am trying to connect a building points with junction point by 2 lines. For demo, I have manually drawn a lines in image 2. Here, I am trying to achieve two things:

  • Connect points (buildings) with Junction by lines.
  • Save the data of start point and end point of connecting lines in seperate table (layer) as shown in image 2 (rightside).

Overall, there will be 3 features in points table and 2 features in line table.

What I have tried and search?

  1. I have tried points to path using Menu Processing / Toolbox / points to path. It only connect one building with junction point with no attributes (startpoint,endpoint) saved in the table.
  2. I have also searched for the exisiting answers 1, 2, 3, 4 but I couldn,t able to solve the problem.

![enter image description here

![[2]: https://i.stack.imgur.com/AAp3O.png

One Answer

You can use Menu Processing / Toolbox / Geometry by expression to create the lines you want:

if ( 
    "Class" = 'building' ,
    make_line (
        $geometry, 
        geometry (
            get_feature (
                'points', 
                'Class', 
                'junction'
            )
        )
    ),
    NULL
)

enter image description here

If you want to have start- and end points as actual geometries/separate layers, you can just use Menu vector / Geometry tools / Extract vertices and set the lines created before as input.

To visualize start- and endpoint of this line (without creating actual geometries/new layer), add a new symbol layer / Geometry generator / geometry type: point and add the following expression (see screenshot below).

collect_geometries (
    end_point ( $geometry ), 
    start_point ( $geometry )
)

enter image description here

Answered by babel on January 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP