Select and calculate area, length and perimeters of features in QGIS



Select and calculate area, length and perimeters of features in QGIS

Select and calculate features according to area, length and perimeters in QGIS. Let us explore some selection technique and also how to use calculation in QGIS. To calculate these parameters we have to change the unit of the calculation to meters. If the layers are in WGS84 CRS we will get measurement in degrees, so first we have to change the CRS of our layers as well as our project. You can also look over other tutorials in QGIS.

To do this, we will import the vector layers which are in projected CRS and change the project CRS by changing project properties. For this map we have selected WGS 84/ UTM Zone 43N CRS you can select zone as per your region.

Select and calculate area, length and perimeters of features

Let us select the features which have area greater than 1000 meter square and save these features into different layer. To complete this task we need to implement following steps:

1.) Open QGIS and open a polygon shapefile layer in QGIS. Select the opened layer for which you want to calculate area.

 2.) Now click select feature using expression, from the tool box.  This will open up one window as shown below.

3.)Find $area by going into geometry and select it by double clicking on it.

Select and calculate area, length and perimeters of features

4.) Set the query as shown in image. Click select and then close.

5.) Feature which have area > 1000 have been selected and highlighted as yellow color.

Select Within Selection Filter

1.) Now we want our selection to be more specific. We don’t want grounds in our selection but only buildings specifically which are university teaching department. To do this, lets implement steps.

2.) Again open select feature using expression tool. We will go to fields and values and select amenity. On clicking it we will get all unique values in the amenity field. We set the query as shown in the image.

Select and calculate area, length and perimeters of features

3.) Don’t click on select instead click on drop-down near it and click select within selection and then close.

4.) Look at the results.

5.) This selected layer can be saved as another file by just Right click on the layer and click save as.

6.) Click on the option save only selected features. Click on browse button and save the layer to the desired destination. The layer will be saved and added to your canvas.

Select and calculate area, length and perimeters of features

Calculate Length of features

There are many ways to calculate these Length, area, perimeter etc parameters. It depend on us which way we select. The result will be the same all the time. Let us check them one by one.

1.) Open the attribute table of the roads layer and then Click on the field calculator.

2.) You will find three options to calculate and take a look on values, as follows:

  • Create a new field: A new field will be created and editing will be automatically enabled so that you can save the new field.
  • Create a virtual field: A new field will be created and editing will be automatically enabled so that you can save the new field, and if you don’t want to save it will automatically delete the column when you close the attribute table.
  • Update existing field: This will update the existing field with the new data.

3.) Set the calculator as shown in image. Click OK and take a look at the attribute table.

Select and calculate area, length and perimeters of features

4.) You can see that the toggle editing tool has been activated automatically. Save edits. And close the attribute table.

5.) Now let’s calculate length with another method. Click on toggle editing tool in the attribute table. Then click on new column.

6.) Fill the text boxes and click ok. And then click save edits.

7.) Now again click on the field calculator and click on the update existing field, select length from the Drop-down menu.

8.) Calculate the length as above and click ok.

9.) The field is updated. Click on save edits and then click toggle editing to disable editing. You can also delete a column or two by going into editing mode and click delete column.

10.) Now let’s take a look at another method. We can calculate length without going into field calculator also. Create a new column as shown above and then select the column here as shown in image.

11.) Click on the expression dialogue sign in front of the column name.

Select and calculate area, length and perimeters of features

12.) Now you can calculate the length by selecting $length. Click ok. You will see the column is not updated.

13.) Click on update all button.

14.) Now the column will be updated. Click on save edits. Then disable editing.

15.) If you want to calculate length for a particular feature only for example length of primary roads only so first select the row which contains primary roads and then calculate length and then click on the button update selected.

Similarly you can select filter features and also calculate length, area, perimeter etc in QGIS. If you are getting any problem in following the steps provided, do comment below with the problem statement. This will let us to discuss over it.

Author: Akshay Upadhyay

Owner and Director of a Private Limited company which serves individual to large scale industries in the field of Maps and GIS. He is a Gold Medalist in M.Tech(Spatial Information Technology) and owns some famous Technology blogs and website... Know more

3 thoughts on “Select and calculate area, length and perimeters of features in QGIS”

  1. Hi

    Thanks for the tutorial, very informative and explainative.

    Unfortunately it seems that no matter which of the methods I try it doesn’t work om layers where I have made the polygon of which I need the length myself – the result is ‘null’ and when i try to update a dialouge box turns up saying (loosely translated) “An error accured at evaluating the calculationstring: No rootknot! Interpretation failed?”. Is it possible at all to calculate lengths of polygons of this “homemade” type?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.