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.

I have a polygon vector and I want to quickly attain the centroid of this polygon for insertion in a text document. I am working with QGIS. I searched through other questions and although some are somewhat close they don't quite answer my question.

Ideally, the centroid coordinates would be in the attribute table of the polygon and I could just copy and paste the coordinates.

I don't want to have to create a separate point vector file that represents the centroid and then find these coordinates and copy and paste them.

share|improve this question
    
What format is your text document? –  Nathan W Jan 6 '13 at 22:21
    
It is a MS word document but really it could be anything. –  David Jan 10 '13 at 16:05

3 Answers 3

A centroid is per definition a point layer and not a polygon. Therefor you need to create a new layer, which is easy as pie in QGIS 1.8 and higher versions.

  • Load in your polygon
  • Go to the menu -> Vector -> Geometry tools -> polygon centroid and create a centroid point layer
  • Export the coordinates of the created centroid to the attribute table by clicking on -> vector Menu -> Geometry tools -> Export/Add geometry columns.

Afterwards you could make a spatial join to add the centroids columns to the polygons and delete the point layer again.

share|improve this answer
    
Thanks for the reply I appreciate the help. Still, this is a lot of work simple to know what the coordinates of the centroid is. Too bad there isn't a simpler way in QGIS. –  David Jan 5 '13 at 20:26
    
If you still want it easier you might take a look at PostGIS and the ST_Centroid function mentioned below. This way you don't need to create temporary files. Alternatively you could write yourself a python script for QGIS or use the SEXTANTE Modeler. –  Curlew Jan 5 '13 at 22:09

Really, making a new shapefile is one of your easiest options. However, you don't need to copy and paste coordinates. Do this:

  • Make your centroids file using the Polygon Centroids tool.
  • Open the centroids attribute table and make it editable (pencil icon at the bottom).
  • Open the field calculator (calculator icon at the bottom) and choose the Create New Field option and call it something meaningful (e.g. Easting).
  • From the functions List expand the Geometry menu and choose $x then repeat with a new column for $y (calling it Northing, say).
  • Save your edits and now you have all the coordinates as part of the attribute table complete with the original polygon ID and attributes if you used the centroids tool.

Alternatively you will have to import your data into PostGIS and then iterate over the polygons, using the ST_Centroid function and store the result in a new field. The work involved is about the same but the second option means you don't have a separate centroids point file.

share|improve this answer
    
Thanks for the answer. I appreciate your help. It seems like Curlew's answer is a bit easier for me. Still both of these answers are a lot more work that I wanted. In the end you end up with various shapefiles that you have to name, delete, edit, etc. –  David Jan 5 '13 at 20:28

Associate the centroid points table with the table of the polygons and then out put the coordinates with the polygon name and shape. Polygons don't have one lat long in and of themselves

share|improve this answer
    
Thanks for your answer. Yes I realize polygons don't have one lat long in and of themselves it simply something that can be calculated. Unfortunately, it isn't easier than this in QGIS. Thanks again everyone for the answers. And so fast too. Thanks! –  David Jan 5 '13 at 20:30

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.