Identifying the two points ending a line in QGIS

proximityqgisqgis-3

Project : footpath going from point to point
I have two layers
Layer 1 points, each point is corresponding to a stake showing a unique number (the unique id of this layer
Layer 2 lines, the route going between each point. Between each point is a single line.

I want to create a field in layer 2 that will be populated with the unique number of the 2 points (start and end)
Example:
layer points : 3 points 1,2,3
layer line, 3 lines : point 1 to 2, 2 to 3, 3 to 1
the field should be respectively populated with 1-2, 2-3, 3-1

The points are exactly at the start/end of lines, snapping was used to create them

How can I do this using
QGIS version 3.16.16? I have no idea how to make this.

Best Answer

You can use Field Calculator.

function aggregate Returns an aggregate value calculated using features from another layer.

aggregate(layer:='checkpoint', aggregate:='concatenate', expression:="checkpointid", filter:=intersects($geometry, geometry(@parent)), concatenator:=',')

enter image description here

Related Question