I am new to QGIS. I am creating a shapefile that will have several polygons. I need to have a column in the attribute table that will show the acres of each polygon. I have successfully done this but when I draw new polygons they don't get their acres calculated. What is the simplest way to overcome this? I am under the impression that this could perhaps be accomplished through GRASS or Python. I don't know anything about these programs though. Ultimately, I need to have a simple system for drawing new polygons labeling them with a field ID and having the ares calculated and labeled. This needs to be simple enough that interns who have never used gis can pick it up relatively quickly.
[GIS] How to compute area in acres in QGIS
areaqgis
Related Solutions
I will admit to an aversion to the "higher level" functionality in Spatial Analyst, such as the clipping and area tabulation, because too many undocumented operations go on under the hood. In the effort to simplify these operations, the software developers have made them less transparent, whence less reliable, and thereby much less useful. The closer you are to the details of the calculation, the more likely you are to understand it and to get the correct answer.
So, motivated by that, consider using combine to overlay the watershed grid and the permeability class grid. The result of combine is to create one code for every distinct ordered pair of (watershed id, imperviousness class) values occurring within the cells. In addition, two fields are adjoined to the attribute table: one gives the watershed id and the other gives the imperviousness class. As always, there is a [count] field, too: multiplying this by the square of the cellsize (and converting to any area unit you prefer, such as acres or square miles) gives the answers you're looking for. The multiplication is readily done with the Field Calculator or by exporting the attribute table and using other software (like a spreadsheet) or even by multiplying the grid itself (inefficient, but it works), provided the multiplicand is an integer.
(Evidently, tabulate areas attempts to do these two operations at once: combine and multiplication by the squared cellsize. It's not much of a savings in user time, especially when you factor in the additional search for (nonexistent?) documentation about what's really going on...)
A Polygon vectorlayer is composed of many features (geometries), each with an area.
If the geometries don't overlap, you can iterate over the vector layer and sum the areas:
layer = iface.activeLayer()
areatot = 0
for elem in layer.getFeatures()
geom = elem.geometry()
areatot += geom.area()
or in one line:
aeratot = [sum(elem.geometry().area() for elem in layer.getFeatures())]
But if some geometries overlap, this result is wrong:
You can then Union all the geometries and use the area of the resulting geometry:
# creation of a empty geometry for unioning
geomtot = QgsGeometry.fromWkt('GEOMETRYCOLLECTION EMPTY')
# union
for elem in layer.getFeatures():
geomtot = geomtot.combine(elem.geometry())
area = geomtot.area()
For QGIS 1.8:
layer = qgis.utils.iface.activeLayer()
areatot = 0
layer.select()
for elem in layer:
geom = elem.geometry()
areatot += geom.area()
and:
geomtot = QgsGeometry.fromWkt('GEOMETRYCOLLECTION EMPTY')
layer.select()
for elem in layer:
geomtot = geomtot.combine(elem.geometry())
area = geomtot.area()
Best Answer
Activate edit mode, and open field calculator. There, use the Geometry -> $area function on existing field, or create a new field. Note that the units are the same as your CRS, so if it's in square meters, multiply by 0.00024711