3

I have a layer that contains a number of fields, two of which are "East" and "North".

I would like to be able to set up the layer so I fill out the attribute form including entering the east and north, and the geometry field is calculated on save.

I would also like it to update the geometry field on an edit of the east or north field.

I did find calculated fields and can manually get it to update, but can't figure out how to "define" this so it automatically happens.

Taras
  • 32,823
  • 4
  • 66
  • 137

1 Answers1

4

Let's assume there is a point layer called 'random_points_test' with several features in it, see image below.

input

Hereupon I am suggesting two cases, because there is a bridge between geometry and attribute table, and one can have an impact on another as well as vice versa.

In both cases Check the Properties > Attribute Form > Defaults and tick the Apply default value on update, see image below.

Case 1 : when a change in the attribute table leads to a change of the geometry

The solution was described here: Updating feature geometry from attribute fields in QGIS.

window1

before :
case1_before

after :
case1_after

Case 2 : when a change of the geometry leads to a change in the attribute table

window2

before :
case2_before

after :
case2_after


References:

Taras
  • 32,823
  • 4
  • 66
  • 137
  • I feel like this does the opposite of what I want. Does this not take the centroid coordinates of the geometry (in this case the point coordinates), and assign them to the fields "East", and "North"? I actually want to do the opposite. Something like updating the geometry feild to = geom_to_wkt(make_point("East", "North")) any time there is an add or edit action? – Andrew Toole Mar 24 '22 at 22:04