Create a field that concatenates multiple intersections in QGIS

Let's assume that you want to join a field by location on a segment that has multiple intersections. For example, let's assume the following diagram:

ASCII
            +
            D
            
+--------+----------+
A        B          C

'Point' layer attributes:

ASCII
|     Name      |
================
|      A        |
|      B        |
|      C        |
|      D        |
================

'Line' layer attributes:

ASCII
|     Id        |
================
|    Line       |
================

If you wish to include the points that intersect with the line, create a new field, for example 'Intersec', on the 'Line' layer using the following formula:

QGIS
array_to_string(overlay_intersects('Point', Name), ',')

Result:

ASCII
|     Id        |     Intersec   |
================ ================
|    Line       |       A, B     |
================ ================

As you can see, the point C is not detected by the previous formula. When the point is snapped to the edge, you might encounter some issues due to the nature of QGIS. To address this, create a small buffer for the line and then perform the point intersection again.

Final result:

ASCII
|     Id        |     Intersec   |
================ ================
|    Line       |     A, B, C    |
================ ================

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.