Adding geometry columns to attribute table of vector map

What if you have a vector polygon layer and you want to add a column to the attribute table with the size (area) of each individual polygon? Very simple in QGIS, just go to the vector menu: vector | Geometry tools | Export/Add geometry columns, which will give you the following input screen:

As you can see, you only need to add the path and name of the output shapefile and you are set. In the output file, two columns will be added to the original attribute table with the area and perimeter of each mapping unit / polygon. See for example the screenshot below with (1) the attribute table of the original layer and (2) the attribute table of the newly created layer with the two added columns with the area and perimeter. Note that the type of geometry will depend on the type of vectors you are working with. If you use line vectors, this tool will create a column with the length of the line elements.

Can’t get much simpler then that I would say :-). And see here for an example why you would want to create those columns to start with. Another example where you’ll need the size of the polygons is if you want to label the polygons in a vector map, but want to avoid labeling the very small once to avoid clutter. See this post by underdark how this can be done.

See my next post to see how to get geometry values using GRASS GIS. Using GRASS GIS for this is slightly more elaborated, but it also offers more options.

About these ads

About pvanb

I am a tropical forest ecologist with a focus on spatial and temporal patterns and processes at population and ecosystem level. I am furthermore very interested in issues related to conservation and sustainable use of biodiversity and natural resources under current and future climates. I have worked in the Middle East (Syria and Lebanon) and South America (Brazil) and in Eastern Africa (Kenya).
This entry was posted in Data handling, GIS, QGIS and tagged , , , , , . Bookmark the permalink.

3 Responses to Adding geometry columns to attribute table of vector map

  1. johnb says:

    Nice idea labeling polys conditional on area – I like it. Enjoying learning more about qgis.. I’ll be very happy to leave ESRI behind one day. Not that I don’t like using it, but it’s the only reason I need to dual boot Windows.

    • pvanb says:

      I occassionally use Windows (on virtual box), but not for ArcGIS. I left that behind some time ago at a time I couldn’t afford it. Now I can get a copy through the university, but I really don’t need it anymore; QGIS, GRASS GIS and R cover all my needs.

  2. Pingback: Add geometry values to vector layer in GRASS GIS | Ecostudies

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s