2

I am using QGIS 3.10 for windows, and I am trying to create a shapefile such that I can load it into QField and take points in the field, and have those points auto generate their coordinates. I have tried using the $x and $y expressions, but they either are not working or not saving, because every time I try to create a point the Easting and Northing fields are still NULL and when I go back into the Field Calculator the expression is blank. Below are my attribute table and attributes form showing the expression:

Here is my attribute table

Here is the attributes form

4

Try to insert this $x and $y expression in "Default value" field and check "Apply default value on update" box.

2
  • Thank you! I will try everything and see if anything helps – Charlene Sep 19 '20 at 22:08
  • Hi I think this worked!! The coordinates are decimal degrees not in easting and northing but I think I can figure it out thank you! – Charlene Sep 21 '20 at 13:53
1

If you have you data in Geopackage, you can use triggers for that.

Same examples:

-- Trigger to calculate the coordinate X/Y of a newly added point geometry

CREATE TRIGGER insert_x AFTER INSERT ON points BEGIN UPDATE points SET x = st_x(geometry); END;

-- Trigger to calculate the coordinate X/Y of an edited point geometry

CREATE TRIGGER update_x AFTER UPDATE OF geometry ON points BEGIN UPDATE points SET x = st_x(geometry); END;

1
  • Thank you! I will try everything and see if anything helps – Charlene Sep 19 '20 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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