5

I have a problem with my layer attributes in QGIS, every time I add $x and $y coordinates as attributes, they are always returned to me in meters, while I would need this data expressed in degrees.

I changed the properties of the project in Project > Properties > General > Show coordinates in use > Geographical map (degrees), but nothing changed.

How can I fix it?

enter image description here

1
  • What is crs of the layer? Apr 5, 2023 at 10:14

1 Answer 1

11

The Show coordinates in use option is for visualization purposes. It doesn't affect the expression.

You need to transform. Use this for X:

x(transform($geometry, @layer_crs, 'EPSG:4326'))

and for Y:

y(transform($geometry, @layer_crs, 'EPSG:4326'))

enter image description here

2
  • thank you so much works perfectly! is there a way to set the ddegrees as the default output?
    – Luke
    Apr 5, 2023 at 11:41
  • I don't think there is. But I am unsure though. Expressions use the layer's crs. Apr 5, 2023 at 11:42

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.