Calculating Polygon Areas in GRASS GIS
While playing around with the ever useful GRASS GIS, it occured to me that I often do all of my ‘simple’ tasks in QGIS and only break out GRASS for the heavy analysis. This means that I don’t always know how to do some basic tasks using GRASS directly. This became apparently while trying to calculate areas on a polygon layer using GRASS. It turns out that it’s a simple task, once you know how, but—as with most things GRASS—can be a bit tricky at first. So, how do we do it?
Basically, the idea is to create a new column where the area data will live:
v.db.addcol mapname col=”area_sqkm DOUBLE PRECISION”
Then we’ll fill the new column with the area using v.to.db. Note that v.to.db will also let you calculate a lot more than just the area; see the full list.
v.to.db map=mapname option=area col=area_sqkm unit=k
Other options for units are:
- Mi: miles
- F: feet
- Me: meters
- K: kilometers
- A: acres
- H: hectares
- R: radians
- D: degrees
Enjoy!
Posted: November 28th, 2012 under GIS.
Comments
Comment from Toto
Time September 6, 2016 at 7:48 am
> v.db.addcol mapname col=”area DOUBLE PRECISION”
v.db.addcol: command not found
Comment from darrencope
Time September 6, 2016 at 7:55 pm
Sounds like your install isn’t correct, or your path isn’t set up to include your GRASS install.
Comment from Luís
Time February 9, 2019 at 10:41 am
There is no module named v.db.addcol in GRASS.
Comment from darrencope
Time February 9, 2019 at 1:34 pm
Hi Luis, it looks like in GRASS 7, the command is called v.db.addcolumn
Comment from Wilber
Time July 13, 2015 at 5:35 pm
It is not needed to use a column, if you want to see on the fly, just can add -p option; it will only print in cmdline