Tuesday, 7 November 2017

Using Field Calculator in QGIS to update columns with centroid coordinates


In QGIS I would like to update two columns with the centroid easting and northing of my polygons. I am using the field calculator. I have tried using $x and $y but this only seems to work for points.


I have checked the help but it does not seem to mention being able to do this.



Answer



A fast way (without field calculator) would be to




  1. create a centroid layer: Vector - Geometry Tools - Polygon Centroids

  2. join the centroid layer to the polygon layer: (Polygon) Layer Properties - Join tab


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...