I have a point layer in EPSG:23700, but I want to save coordinates into the attribute table in a different CRS (EPSG: 4326), without transforming/changing the layer (I want to keep it in EPSG:23700).
I would do this in Field Calculator:
x(transform($geometry, layer_property(@layer_id, 'crs'), 'EPSG:4326'))
Is there a way to do this with Python?
Btw. I am saving the original coordinates with this simple code (I want to extend this):
layer = iface.activeLayer() selected_feature = layer.selectedFeatures() layer.startEditing() for feature in selected_feature: feature["EOV_X"] = feature.geometry().asPoint() feature["EOV_Y"] = feature.geometry().asPoint() layer.updateFeature(feature) layer.commitChanges()