Using Field Calculator in QGIS to update columns with centroid coordinates
Not sure if it worked 5 years ago, but now the solution looks like this:
x(centroid($geometry))
and
y(centroid($geometry))
Results are the same as while using the "Join"
option mentioned above:
A fast way (without field calculator) would be to
- create a centroid layer: Vector - Geometry Tools - Polygon Centroids
- join the centroid layer to the polygon layer: (Polygon) Layer Properties - Join tab