0

When using the $x and $y commands in the field calculator to get coordinates of features in a point layer, the coordinates I get are different than if I point the feature with my cursor. The deviation is over 200m metres between de coordinates given by the field calculator and the ones given by the cursor in the current map coordinate window. The project and all layers are set to EPSG 25831. To confere how big is the difference between coordinates generated depending on the tool or the way you calculate them I proceeded as follows:

  • I created a point layer with fields set to give the x and y coordinates through the $x and $y field calculator expressions.
  • I drew a point feature using the advanced editing tool to set x and y coordinates (in my case 276790 - 4548743).
  • This same point feature is given an X and Y coordinates by the field calulator expressions, quite different than the ones I set to create the point feature. More specifically these are 276880 - 4548943.
  • I repeated de procedure of drawing a point feature with the 276880 - 4548943 coordinates using the advanced editing tool, resulting in a displacement of 219m between the two points.

This kind of inaccuracy can lead to serious errors in the final results the qgis project is expected to produce.

5
  • 2
    What are your measurement settings in the project properties? What happens when you use x($geometry)?
    – Erik
    Commented Feb 8 at 8:54
  • there could be some rounding going on. Maybe check the field type and length of the field where you calculate the coordinates
    – nepluisse
    Commented Feb 9 at 8:37
  • 1
    Consider posting a sample (cut down) dataset with this problem - it would allow people to investigate it rather than guessing. Commented Feb 18 at 23:50
  • In addition to measurement settings in the project please also provide information about your cursor accuracy and canvas zoom level.
    – MrXsquared
    Commented Feb 22 at 15:06
  • What if you start a new project from scratch and repeat the process you outline above? I did that and my point had the correct co-ordinates. Consider posting your cut down dataset - it's hard to resolve issues like this without the actual data, given that the process worked fine for me. Commented Feb 23 at 8:20

1 Answer 1

0

There are multiple possible explanations:

  1. Coordinates you get by moving the cursor and reading them from the statusbar are inherently inaccurate. There are a lot of factors that contribute to this: mouse sensitivity, cursor size, symbology size, map scale, small rendering inaccuracies, possibly some others. In contrast, the geometry expression should return what is actually written in the data source, and that is where your feature is, for any practical purposes.

  2. You mention that you use a single CRS and that it is properly set everywhere, but for the sake of completeness I include how CRS settings can contribute to such a situation. Geometry expressions $x and x(@geometry) (apparently) both return coordinates in layer CRS. If your layer and project CRS are slightly different, then you can get somewhat different values than from the cursor. If they are very different, then the returned coordinates could appear to be complete bogus, while being actually valid.

  3. A way to further check is to use the Identify Feature tool. It returns feature coordinates, along with clicked coordinates in project CRS. You will see that there's some difference between the two, even when you are zoomed in.

0

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.