I'm using QGIS 3.10 with Python 3.7.
I have two layers: "line_layer" and "vertices_layer". I want to add only the names of my vertices (attributtable: "node_name") to the attributtable of my "line_layer" (like start and end node --> attributtable: "node_start" and "node_end"). I have a net so for one line a point A is the start, while for another line this point A is the end. Thats why I can't divide my vertices into start-/endpoints. I want to do this in the console using python (I'm a beginner). My (definetly wrong) code is:
for f in line_layer.getFeatures():
geom = f.geometry().asMultiPolyline()
start_point = QgsPoint(geom[0]) #first point
end_point = QgsPoint(geom[-1]) #last point
f.['node_start'] = QgsGeometry.nearestPoint(start_point)
f.['node_end'] = QgsGeometry.nearestPoint(end_point)
line_layer.commitChanges()
The code doesn't work and I don't know how to get only th name of the nearest point in the attributtable of my line_layer.
Just for understanding the situation:

