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.


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'),

For field x/lon:

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

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


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.