0

I have the situation, where I draw the lines from one point to another. They in fact proceed along with the other linear items, but it works well with the snapping tool.

enter image description here

As you can see I must fill up the from and to columns, where, from is the one end of my line finishing at the point with ID 34499 and another end (to) is the point with ID 64974. Is there any way to do it automatically in the attribute table?

1 Answer 1

0

This can be done in 3 steps:

  1. Create a new WKT field in the Points layer

geom_to_wkt( $geometry)

  1. Update the from field in the line layer with the following formula
    (assuming your points layer is called 'Points' and the name/ID field is called 'NAME'):
to_string( attribute(get_feature('Points','WKT', geom_to_wkt(start_point($geometry))),'NAME') )
  1. Update the to field in the line layer with the following formula
to_string( attribute(get_feature('Points','WKT', geom_to_wkt(end_point($geometry))),'NAME') )

As stated this is assuming your points layer is called 'Points' and the name/ID field is called 'NAME'. If this not the case, update those values in the formulas.

Adapted from this answer: https://gis.stackexchange.com/a/209368/10661

Steps involved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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