Feature request #4857

Add unit type to $area calculation

Added by Pierre-Luc Auclair over 5 years ago. Updated over 1 year ago.

Status:Closed
Priority:Normal
Assignee:-
Category:-
Pull Request or Patch supplied:No Resolution:
Easy fix?:No

Description

When I calculate areas, it would be useful to specify directly the unit type I want in my field.

The way I see it working is this : $area(unit)

Where "unit" is a unit abbreviation, say km, m, ha, etc.

I always find transferring square meters to other units with calculations cumbersome as I have a hard time remembering how much I should divide or multiply values.

Thanks !

Associated revisions

Revision 9f772bce
Added by Nyall Dawson over 1 year ago

Add API call for setting preferred distance unit for QgsExpression

(refs #13209, #12939, #4857)

Revision ddbdcf8a
Added by Nyall Dawson over 1 year ago

Fix project unit confusion (pt 2): add project distance unit setting

Adds a new option in project properties to set the units used for
distance measurements. This setting defaults to the units set in
QGIS options, but can then be overridden for specific projects.

The setting is respected for length and perimeter calculations in:
- Attribute table field update bar
- Field calculator calculations
- Identify tool derived length and perimeter values
- Default unit shown in measure dialog

Also adds unit tests to ensure that length and perimeter calculated
by attribute table update bar, field calculator and identify tool
are consistent wrt ellipsoidal calculations and distance units.

(refs #13209, #12939, #2402, #4857, #4252)

Revision dfdcec89
Added by Nyall Dawson over 1 year ago

Fix project unit confusion (pt 3): add area unit settings with a
ton of available area units (eg m2, km2, mi2, ft2, yd2, ha, ac,
etc)

Adds a new option in both the QGIS setting and project properties to
set the units used for area measurements. Just like the distance
setting, this defaults to the units set in QGIS options, but can
then be overridden for specific projects.

The setting is respected for area calculations in:
- Attribute table field update bar
- Field calculator calculations
- Identify tool derived length and perimeter values

Also adds unit tests to ensure that area calculated by attribute table
update bar, field calculator and identify tool are consistent wrt
ellipsoidal calculations and area units.

TODO: make measure tool respect area setting

(refs #13209, #4252 and fixes #12939, #2402, #4857)

History

#1 Updated by Paolo Cavallini about 5 years ago

This is partly implemented in fTools now.

#2 Updated by Alister Hood about 5 years ago

Also see #4078: Enable CRS conversion in field calculator

#3 Updated by Giovanni Manghi about 5 years ago

  • Target version set to Version 2.0.0

#4 Updated by Pirmin Kalberer over 4 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

#5 Updated by Antonio Locandro almost 3 years ago

Units would be nice to have also in the Output Preview, that way I would know

$area

Output preview - 10 m

Then I could decide I want ft instead then using something like

$area(ft)

Output preview - 3.04803706413 ft

#6 Updated by Nyall Dawson over 1 year ago

  • Status changed from Open to Closed

Also available in: Atom PDF