Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
hmm doesn't seem possible at the moment. Shouldn't be too hard to add in. –  Nathan W Jul 1 '11 at 9:22
    
Any easy thing should be adding centroids to the columns added by "Export geometry columns" –  underdark Jul 1 '11 at 10:44
add comment

2 Answers

up vote 9 down vote accepted

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
share|improve this answer
    
Thanks for the answer. I had figured out I could do it this way, I just wondered if there was a way to do it through field calculator like for points. –  James S Jul 1 '11 at 10:37
add comment

If you would consider doing it in workaround method here's how I did it:

Export your polygon as MapInfo file

Calculate centroids with Vector > Geometry Tools > Polygon Centroids

Export centroids as MapInfo File

Remove all unneeded info from Centroid MIF file, leave just coordinates

In your polygon MIF file add information that you have 2 more columns (x and y/lat and long) don't forget to update column count information.

In your polygon MID file copy all columns from centroid MIF file (excel will help here)

There might be a shorter/direct way to do this, but maybe my answer will help you.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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