I have a polygon shapefile which I have imported into QGIS, however it does not display X Y coordinates. Is there a way that I can identify the coordinate for the centroid of the polygon and display this in the attribute table?

  • 1
    It's certainly possible, but first you need to identify the meaning of "centroid", since there are several options, and not all of them are "inside" the polygon. – Vince Nov 23 '16 at 12:00

The QGIS field calculator can do it with these built-in functions:

 x( centroid(  $geometry ))
 y( centroid(  $geometry ))

Make sure to create a new field of type real, with an accuracy of 8. You can even use a virtual field to avoid changing the datasource.

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.