4

Is it possible in QGIS to quickly calculate the area of a polygon using a Processing tool, plugin, script without adding attributes or creating a new layer?

Something launching the results window or even a point and click feature?

0

5 Answers 5

10

The identify tool does offer you this information.

Click any feature, then expand the topmost dropdown menu. Here all basic geometric information is hidden, incl. the area and circumfence.

enter image description here

1
  • This is the kind of solution I was looking for, definitely. Some of the answers below are more helpful, but this is what I had in my mind for a quick check.
    – IberOikos
    Nov 13, 2021 at 11:36
10

Create a label with the expressin $area (I should have used round($area)):

enter image description here

1
  • 2
    Most obvious and easy option.
    – Erik
    Nov 12, 2021 at 11:34
8

I personally find the identify tool sometimes too clunky. Here another approach:

To show the area for a polygon without using an additional field, you can just use a formula for a label with the $area function, e.g.:

round($area/10000,1)

will give you the area of the features in hectares.

As you just want to see the area when pointing/clicking, you could add

CASE
WHEN  is_selected() THEN round($area/10000,1)
END

When you now use the select tool pointing on a polygon, it will show the area label. enter image description here

In case your polygons already have a label based on some field(s), you can extend the formula with an ELSE statement to switch between normal view and selected view:

CASE
WHEN  is_selected() is FALSE THEN "id"
ELSE round($area/10000,1)
END

enter image description here

Please mind that I never have used this approach myself, I just came up with this idea while reading your question.

1
  • I tried both methods and it worked perfectly, an elegant solution.
    – IberOikos
    Nov 13, 2021 at 11:42
4

Also possible by means of PyQGIS.

def feature_area(selected, _, __):
    n = len(selected)
    
    if n == 1:
        g = iface.activeLayer().selectedFeatures()[0].geometry()
        print("The area of selected feature is " + '{:0,.2f}'.format(g.area()) + " m²")
        
    elif n > 1:
        print("Select only one feature")

iface.activeLayer().selectionChanged.connect(feature_area)

result

Inspiration was found in: Determining number of vertices of selected object in QGIS 3

4

Another option is using the display_icon"Display" through RMC > Properties > Display.

Display

Paste the following expression format_number($area,2,'de') into the 'Display Name' and press Apply.

Note: I made it in very intuitive way, more sophisticated output can be achieved via the 'HTML Map Tip'.

After hover over the feature and get the output

result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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