1

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?

6

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

  • It seems to not work with both expressions as NULL appears with both expression types – Alison Jones May 20 at 19:07
  • Can you provide a sample snippet of your data? – MrXsquared May 20 at 19:10
  • And make sure to choose the correct output field type, e.g. Text (string) for WKT or concatenated coordinates. – MrXsquared May 20 at 19:24
  • How do you make sure its the correct output field? – Alison Jones May 20 at 19:37
  • See my edited answer – MrXsquared May 20 at 19:47

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.