1

This question already has an answer here:

I got vector points on a map. I already have the elevation information in the table for each vector point and the point-id. Now I want to get the GPS coordinates for each point stored in this attribute table. How can I do that?

Overall my aim is to get to know the gradient on this line which I divided into those points.

marked as duplicate by underdark qgis Feb 15 at 18:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

If your layer already is in EPSG:4326 use the following expressions:

  • For field y/lat use: $y
  • For field x/lon use: $x

If your layer is in another projection use:

For field y/lat:

y(transform($geometry, layer_property(@layer_name, 'crs'),
       'EPSG:4326'))

For field x/lon:

x(transform($geometry, layer_property(@layer_name, 'crs'),
   'EPSG:4326'))

Create the fields with fieldcalculator and make sure to set field type to Decimal number (real) and set its precision. enter image description here

2

vector -> geometry tools -> add geometry attributes adds columns with you coordinates in the layers CRS to its attribute table.

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