2

I want to add start and end points to my attribute table for each feature in one layer in terms of actual location and not distance form start meter i.e. start being 0 and end point 10 meters. Is there a way I could do this?

0

1 Answer 1

10

Use the expressions

start_point($geometry) and end_point($geometry)

This expression alone will result in NULL in your attribute table. To make it readable in your attribute table combine it with geom_to_wkt() or x() and y(). For example:

  • geom_to_wkt(start_point($geometry)) (Use Text (string) as field type) or
  • x(start_point($geometry)) || ', ' || y(start_point($geometry)) (Use Text (string) as field type)
  • x(start_point($geometry)) (Use Decimal number (real) as field type)

Enter the expression in your field calculator and make sure to set output field type correctly as well as ouput field length and precision:

enter image description here

3
  • It seems to not work with both expressions as NULL appears with both expression types Commented May 20, 2019 at 19:07
  • And make sure to choose the correct output field type, e.g. Text (string) for WKT or concatenated coordinates.
    – MrXsquared
    Commented May 20, 2019 at 19:24
  • How do you make sure its the correct output field? Commented May 20, 2019 at 19:37

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.