2

I am using QGIS 3.8 and I have a polyline layer with the attribute below

enter image description here

And a point layer with the attribute below

enter image description here

So I wonder if there is an expression to get the field 'Name' of the point layer of the nearest points to the startpoint and endpoint into the fields 'from' & 'To' of the polyline layer (i.e. the field 'From' will get the nearest point 'Name' to the startpoint and the field 'To' will get the nearest point 'Name' to the endpoint or vice versa) as shown below

enter image description here

0
2

You can open the processing toolbox.

Then type in the searcher: Extract specific vertices

Choose the input layer

In vertex indexes type: 0, -1 (first and last point)

After that you can obtain your lat-lon coordinates creating new fields in the field calculator

2
  • 2
    With field calculator, you can also have x (start_point($geometry)) and y (start_point($geometry)) x (end_point($geometry)) and y (end_point($geometry)) You can also using geomnearest function if the start and end points of the polylines are not exactly matching with the point layer Aug 1 '19 at 8:52
  • Thanks for your effort but I do not want the the coordinates of the end and start point. I want the fields 'From' and 'To' get the content of the field 'Name'. I used geomnearest to retrieve the data from the nearest specified layer but I am wondering if I could retrieve the data from the nearest specified layer to the end or start point.
    – Ahmed Alaa
    Aug 1 '19 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.