Subgroup: other
Class: QgsAggregateCalculator¶
-
class
qgis.core.
QgsAggregateCalculator
(layer: QgsVectorLayer)¶ Bases:
sip.wrapper
Constructor for QgsAggregateCalculator.
Parameters: layer – vector layer to calculate aggregate from QgsAggregateCalculator(QgsAggregateCalculator)
Utility class for calculating aggregates for a field (or expression) over the featuresfrom a vector layer. It is recommended that QgsVectorLayer.aggregate() is used rather then directly using this class, as the QgsVectorLayer method can handle delegating aggregate calculation to a data provider for remote calculation.
New in version 2.16: Methods
aggregates
Structured information for available aggregates. calculate
Calculates the value of an aggregate. delimiter
Returns the delimiter used for joining values with the StringConcatenate aggregate. filter
Returns the filter which limits the features used during the aggregate calculation. layer
Returns the associated vector layer. setDelimiter
Sets the delimiter to use for joining values with the StringConcatenate aggregate. setFilter
Sets a filter to limit the features used during the aggregate calculation. setParameters
Sets all aggregate parameters from a parameter bundle. stringToAggregate
Converts a string to a aggregate type. Signals
Attributes
-
class
Aggregate
¶ Bases:
int
-
class
AggregateInfo
¶ Bases:
sip.wrapper
QgsAggregateCalculator.AggregateInfo(QgsAggregateCalculator.AggregateInfo)
-
function
¶
-
name
¶
-
supportedTypes
¶
-
-
class
AggregateParameters
¶ Bases:
sip.wrapper
QgsAggregateCalculator.AggregateParameters(QgsAggregateCalculator.AggregateParameters)
-
delimiter
¶
-
filter
¶
-
-
ArrayAggregate
= 20¶
-
Count
= 0¶
-
CountDistinct
= 1¶
-
CountMissing
= 2¶
-
FirstQuartile
= 13¶
-
GeometryCollect
= 19¶
-
InterQuartileRange
= 15¶
-
Majority
= 12¶
-
Max
= 4¶
-
Mean
= 6¶
-
Median
= 7¶
-
Min
= 3¶
-
Minority
= 11¶
-
Range
= 10¶
-
StDev
= 8¶
-
StDevSample
= 9¶
-
StringConcatenate
= 18¶
-
StringMaximumLength
= 17¶
-
StringMinimumLength
= 16¶
-
Sum
= 5¶
-
ThirdQuartile
= 14¶
-
aggregates
() → object¶ Structured information for available aggregates.
New in version 3.2.
-
calculate
(self, aggregate: QgsAggregateCalculator.Aggregate, fieldOrExpression: str, context: QgsExpressionContext = None) → Tuple[Any, bool]¶ Calculates the value of an aggregate.
Parameters: - aggregate – aggregate to calculate
- fieldOrExpression – source field or expression to use as basis for aggregated values.
If an expression is used, then the context parameter must be set. :param context: expression context for evaluating expressions :param ok: if specified, will be set to true if aggregate calculation was successful
Returns: calculated aggregate value
-
delimiter
(self) → str¶ Returns the delimiter used for joining values with the StringConcatenate aggregate.
See also
-
filter
(self) → str¶ Returns the filter which limits the features used during the aggregate calculation.
See also
-
layer
(self) → QgsVectorLayer¶ Returns the associated vector layer.
-
setDelimiter
(self, delimiter: str)¶ Sets the delimiter to use for joining values with the StringConcatenate aggregate.
Parameters: delimiter – string delimiter See also
-
setFilter
(self, filterExpression: str)¶ Sets a filter to limit the features used during the aggregate calculation.
Parameters: filterExpression – expression for filtering features, or empty string to remove filter See also
-
setParameters
(self, parameters: QgsAggregateCalculator.AggregateParameters)¶ Sets all aggregate parameters from a parameter bundle.
Parameters: parameters – aggregate parameters
-
stringToAggregate
(string: str) → Tuple[QgsAggregateCalculator.Aggregate, bool]¶ Converts a string to a aggregate type.
Parameters: - string – string to convert
- ok – if specified, will be set to true if conversion was successful
Returns: aggregate type
-
class