TransWikia.com

Adding attributes of points to attribut table of lines in QGIS

Geographic Information Systems Asked by Julz_Mos on March 5, 2021

I’m using QGIS 3.8 with GRASS 7.6.1

I want to add only the names of my vertices (from line intersection, duplicates deleted) to the attributtable of my lines (like start and end node). Every line has only two vertices.

What I tried:

  • geom_to_wkt(start_point($geometry)) –> gives me the coordinates (I need the name) of my real nodes not of the vertices

  • "add by position" only transfers the name of one vertices (but I need both)

enter image description here

One Answer

In QGIS I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume we have two layers 'points_layer' (red) and 'lines_layer' (grey) respectively, see image below.

input

With the following query, it is possible to add only the names of my vertices (from line intersection, duplicates deleted) to the attributtable of my lines (like start and end node).

SELECT l.*, p1.Info AS start_point_info, p2.Info AS end_point_info
FROM "lines_layer" AS l
LEFT JOIN "points_layer" AS p1 ON st_equals(start_point(l.geometry),p1.geometry)
LEFT JOIN "points_layer" AS p2 ON st_equals(end_point(l.geometry),p2.geometry)

The output Virtual Layer will look like as follwoing

result


References:

Correct answer by Taras on March 5, 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