4

I want to use the "Line Intersection" function in QGIS to create points wherever lines cross. The lines are roads and I need the road names in my points layer.

Does anyone have an idea how I can add the street name of each line to the point layer without creating points twice? The street names are in the input layer (osm roads).

The first image shows what it looks like when I use the line intersection feature. I have 12 point features for the same intersection. The second image shows how it should be. The other data is not important for me.

Not what I want:
enter image description here

That's how it should be:
enter image description here

Taras
  • 32,823
  • 4
  • 66
  • 137
lena
  • 179
  • 1
  • 9

1 Answers1

5

Use the Field Calculator with this expression:

array_to_string(
  array_sort(
    array_distinct(
        overlay_touches(
            layer:='lines_layer_name', --specify the name of your line layer 
            expression:="name_2") --specify the targeting field
        )
    )
)

This expression utilizes the following functions: array_sort(), array_distinct(), and overlay_touches().


References:

lena
  • 179
  • 1
  • 9
Taras
  • 32,823
  • 4
  • 66
  • 137
  • 2
    Thank you very much! I worked with a short addition:

    array_to_string( array_sort( array_distinct( overlay_touches( layer:='Test_osm', --specify the name of your line layer expression:="name") --specify the targeting field ) ) )

    – lena Jun 13 '22 at 14:00