124

How do I calculate areas of an area shapefile in square meters (m²) or in acres (ha)?

I didn't find that functionality in the Vector Tools.

0

8 Answers 8

130

Make the layer editable, then use the field calculator (Layer > Open attribute table > Field Calculator/Ctrl+I or right mouse click shapefile > Open attribute table > Field Calculator/Ctrl+I).

There is an operator $area that will calculate the area of each row in the table. All units will be calculated in the units of the projection, so you probably want to project it to a projection that uses feet or meters before doing that, rather than lat/lon.

Note the differences between $area and area($geometry):

About $area from the QGIS Documentation

Returns the area of the current feature. The area calculated by this function respects both the current project’s ellipsoid setting and area unit settings. For example, if an ellipsoid has been set for the project then the calculated area will be ellipsoidal, and if no ellipsoid is set then the calculated area will be planimetric.

About area($geometry) from the QGIS Documentation:

Returns the area of a geometry polygon object. Calculations are always planimetric in the Spatial Reference System (SRS) of this geometry, and the units of the returned area will match the units for the SRS. This differs from the calculations performed by the $area function, which will perform ellipsoidal calculations based on the project's ellipsoid and area unit settings.

5
  • 11
    In current versions of QGIS if your data is in a Geographic CRS you can use the function transform() to project the geometries to a projected system (Preferably an equal area one) without the need to duplicate your data. In the Field calculator, something like this should work: area($geometry, 'EPSG:4326','EPSG:3763') Commented Feb 3, 2016 at 23:11
  • 37
    @AlexandreNeto: Do you mean area(transform($geometry, 'EPSG:4326','EPSG:3763'))? Commented Apr 20, 2017 at 5:33
  • @smacdonald yes, my mistake. Commented Apr 20, 2017 at 6:58
  • 3
    As of QGIS 3.14, I believe that the units of the $area and $length are in the units that are set in the project preferences, NOT in the layer's units. Be really careful with this.
    – glaroc
    Commented Oct 28, 2020 at 15:47
  • Note that just because a projection has meters as its map unit, doesn't mean it represents areas accurately. Therefore, it's best to use an equal area projection.
    – Joooeey
    Commented Nov 30, 2021 at 11:16
31

This can also be done with Vector|Geometry Tools|Add/export geometry columns, which creates a new shapefile with area and perimeter (or length) columns added.

Edit: (using the tool above, you can also unselect "save as new shape-file" in V1.8, the shapefile is now only updated!)

Using the field calculator is probably a better idea, though, as it doesn't require the creation of a new shapefile.

0
11

If not getting very accurate area calculations does not bother you (or if you do not want to play with different options in the field calculator as mentioned by some of the answers and comments above), in the current version of QGIS (i.e., QGIS 3.12) there is an easy way to deal with this. Go to "Project >> Properties >> General" and change the units for distance and area measurements. Now $area in the field calculator automatically transform the CRS for area (and for other geometric calculations if that matters).

However, I personally recommend doing the method by @Alexandre as it will give you more accurate results. Though you have to do a little search that what will be the 3rd parameter of transform function, i.e., most suitable CRS for your area of interest and its units.

enter image description here

1
  • 5
    That is super important. The $area is no longer calculated in the layer's CRS units. It is calculated in the units set in the project settings.
    – glaroc
    Commented Oct 28, 2020 at 15:49
11

Try using the icon"Identify Features" tool (Ctrl+Shift+I) from the Attributes Toolbar.

result

There will be two attributes: "Area (Cartesian)" and "Area (Ellipsoidal - EPSG:7019)"

Before starting, make sure that the Hide Derived Attributes from Results option is unchecked.

enter image description here

1
  • 1
    Fast and easy, thanks. If you do not need the value for some further calculations or to display it, this is the way to go.
    – Marty
    Commented Feb 7, 2022 at 9:42
7

I wrote a script specifically for this. If you don't want to reproject your data, you can compute the area using ellipsoidal math.

Processing Toolbox -> Tools -> Get scripts from on-line scripts collection -> Ellipsoidal Area

You will find the script installed in Processing Toolbox -> Utils -> Ellipsoidal area

The tool should be self explanatory and will allow you to calculate area in units of your choice regardless of projection.

1
7

If the areas you are looking at are liable to change, such as looking at infrastructure layouts, catchment areas, study areas etc, I find it useful to simply label the areas, instead of adding them as attributes.

Label-> round($area/10000,2)||' ha'

This way you don't need to remember to update the catchment areas in the attribute tables as often.

1
  • 2
    won't this save your values as strings? I would advise against saving numerical data as strings and instead include the area unit in the field name.
    – thymaro
    Commented Feb 26, 2020 at 16:02
2

Search in the Processing Toolbox for the Field Calculator. Select your input layer, give the field a proper name (area for example). Select a datatype (i.e. float) Scroll down to Expression and either click Geometry -> $area or type in $area into the left box. Click Run. Now there is a new (temporary) Layer created. If you look at the Attribute Table you will find a column with the name you gave it ( i.e. area).

If you are interested in the whole area of every feature in the Layer, search for Basic statistics for fields. If you run this, you get statistics like mean, sum, std etc.

0

I would implement the solution described at Geometry based automatic fill of fields in attribute table

The solution is essentially a trigger that will update the field automatically when ever a transaction occurs.

This way, the data will not only populate the field upon data creation, but also if geometry changes.

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