On the line layer, create a new field with field calclulator and the following expression for the start-point. The expression creates a buffer around the start-point of the line, then looks for the two closest points to the line and checks which one lies inside the buffer. From this point, it takes the value of the field
Adapt the expression as follows if necessary:
- For the end-point, simply replace
start_point (line 8) with
points with the name of your point layer and
name with the field-name you want to get.
- Only in case it doesn't work as expected: Change the value of
0.001 at the end of line 8. This is the size of the buffer around the start-point of the line and the expression checks which of the points is within this buffer.
- Only in case you you have several points on your line (not just start- and end-point): increase the value at end of line 4 (now:
2) to the max. number of points that are on a line.
overlay_nearest ('points',$id, limit:=2),
geometry (get_feature_by_id ('points',@element)),
buffer (start_point($geometry), 0.001)
attribute (get_feature_by_id ('points',@element), 'name'),
Get the value of the point layer's
name attribute of the point that lies on the start- and end-point of the line as an attribute on the line layer. Here the expression is used in a combination as a dynamically created label of the line: