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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityThe 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.
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.
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
Please mind that I never have used this approach myself, I just came up with this idea while reading your question.
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)
Inspiration was found in: Determining number of vertices of selected object in QGIS 3
Another option is using the "Display" through
RMC > Properties > 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