2017-05-01 12:15:01 +03:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsstatisticalsummary.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-02 23:19:39 +10:00
|
|
|
class QgsStatisticalSummary
|
|
|
|
{
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Calculator for summary statistics for a list of doubles.
|
|
|
|
|
|
|
|
Statistics are calculated by calling calculate() and passing a list of doubles. The
|
|
|
|
individual statistics can then be retrieved using the associated methods. Note that not all statistics
|
|
|
|
are calculated by default. Statistics which require slower computations are only calculated by
|
|
|
|
specifying the statistic in the constructor or via setStatistics().
|
|
|
|
|
|
|
|
.. versionadded:: 2.9
|
2015-05-02 23:19:39 +10:00
|
|
|
%End
|
|
|
|
|
2017-05-01 12:15:01 +03:00
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsstatisticalsummary.h"
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
public:
|
|
|
|
|
|
|
|
enum Statistic
|
|
|
|
{
|
2017-05-01 12:15:01 +03:00
|
|
|
Count,
|
|
|
|
CountMissing,
|
|
|
|
Sum,
|
|
|
|
Mean,
|
|
|
|
Median,
|
|
|
|
StDev,
|
|
|
|
StDevSample,
|
|
|
|
Min,
|
|
|
|
Max,
|
|
|
|
Range,
|
|
|
|
Minority,
|
|
|
|
Majority,
|
|
|
|
Variety,
|
|
|
|
FirstQuartile,
|
|
|
|
ThirdQuartile,
|
|
|
|
InterQuartileRange,
|
2015-05-03 17:10:32 +02:00
|
|
|
All
|
2015-05-02 23:19:39 +10:00
|
|
|
};
|
|
|
|
typedef QFlags<QgsStatisticalSummary::Statistic> Statistics;
|
|
|
|
|
2017-05-01 12:15:01 +03:00
|
|
|
|
2017-05-01 12:53:35 +03:00
|
|
|
QgsStatisticalSummary( QgsStatisticalSummary::Statistics stats = QgsStatisticalSummary::All );
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Constructor for QgsStatisticalSummary
|
|
|
|
\param stats flags for statistics to calculate
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
virtual ~QgsStatisticalSummary();
|
|
|
|
|
2017-05-01 12:15:01 +03:00
|
|
|
Statistics statistics() const;
|
|
|
|
%Docstring
|
|
|
|
Returns flags which specify which statistics will be calculated. Some statistics
|
|
|
|
are always calculated (e.g., sum, min and max).
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`setStatistics`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: Statistics
|
|
|
|
%End
|
|
|
|
|
2017-05-01 12:53:35 +03:00
|
|
|
void setStatistics( QgsStatisticalSummary::Statistics stats );
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Sets flags which specify which statistics will be calculated. Some statistics
|
|
|
|
are always calculated (e.g., sum, min and max).
|
|
|
|
\param stats flags for statistics to calculate
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`statistics`
|
2017-05-01 12:15:01 +03:00
|
|
|
%End
|
|
|
|
|
2015-05-02 23:19:39 +10:00
|
|
|
void reset();
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Resets the calculated values
|
|
|
|
%End
|
|
|
|
|
|
|
|
void calculate( const QList<double> &values );
|
|
|
|
%Docstring
|
|
|
|
Calculates summary statistics for a list of values
|
|
|
|
\param values list of doubles
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
2016-05-16 08:59:47 +10:00
|
|
|
void addValue( double value );
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Adds a single value to the statistics calculation. Calling this method
|
|
|
|
allows values to be added to the calculation one at a time. For large
|
|
|
|
quantities of values this may be more efficient then first adding all the
|
|
|
|
values to a list and calling calculate().
|
|
|
|
\param value value to add
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
call reset() before adding the first value using this method
|
|
|
|
to clear the results from any previous calculations
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
finalize() must be called after adding the final value and before
|
|
|
|
retrieving calculated statistics.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`calculate()`
|
|
|
|
.. seealso:: :py:func:`addVariant()`
|
|
|
|
.. seealso:: :py:func:`finalize()`
|
2017-05-01 12:15:01 +03:00
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
|
|
|
|
|
|
|
void addVariant( const QVariant &value );
|
|
|
|
%Docstring
|
|
|
|
Adds a single value to the statistics calculation. Calling this method
|
|
|
|
allows values to be added to the calculation one at a time. For large
|
|
|
|
quantities of values this may be more efficient then first adding all the
|
|
|
|
values to a list and calling calculate().
|
|
|
|
\param value variant containing to add. Non-numeric values are treated as null.
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
call reset() before adding the first value using this method
|
|
|
|
to clear the results from any previous calculations
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
finalize() must be called after adding the final value and before
|
|
|
|
retrieving calculated statistics.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`addValue()`
|
|
|
|
.. seealso:: :py:func:`calculate()`
|
|
|
|
.. seealso:: :py:func:`finalize()`
|
2017-05-01 12:15:01 +03:00
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
2016-05-16 08:59:47 +10:00
|
|
|
|
|
|
|
void finalize();
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Must be called after adding all values with addValues() and before retrieving
|
|
|
|
any calculated statistics.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`addValue()`
|
|
|
|
.. seealso:: :py:func:`addVariant()`
|
2017-05-01 12:15:01 +03:00
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
2016-05-16 10:17:56 +10:00
|
|
|
|
2017-05-01 12:53:35 +03:00
|
|
|
double statistic( QgsStatisticalSummary::Statistic stat ) const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns the value of a specified statistic
|
|
|
|
\param stat statistic to return
|
|
|
|
:return: calculated value of statistic. A NaN value may be returned for invalid
|
|
|
|
statistics.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-18 05:55:14 +10:00
|
|
|
|
2015-05-02 23:19:39 +10:00
|
|
|
int count() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated count of values
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
[FEATURE] Aggregates for expressions
This commit adds a number of different forms of aggregates to
the expression engine.
1. Aggregates within the current layer, eg sum("passengers")
Supports sub expressions (ie sum("passengers"/2) ), group by
( sum("passengers", group_by:="line_segment") ), and optional
filters ( sum("passengers", filter:= "station_class" > 3 ) )
2. Relational aggregates, which calculate an aggregate over
all matching child features from a relation, eg
relation_aggregate( 'my_relation', 'mean', "some_child_field" )
3. A summary aggregate function, for calculating aggregates
on other layers. Eg aggregate('rail_station_layer','sum',"passengers")
The summary aggregate function supports an optional filter,
making it possible to calculate things like:
aggregate('rail_stations','sum',"passengers",
intersects(@atlas_geometry, $geometry ) )
for calculating the total number of passengers for the stations
inside the current atlas feature
In all cases the calculations are cached inside the expression
context, so they only need to be calculated once for each
set of expression evaluations.
Sponsored by Kanton of Zug, Switzerland
2016-05-16 17:30:07 +10:00
|
|
|
int countMissing() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns the number of missing (null) values
|
|
|
|
.. versionadded:: 2.16
|
|
|
|
:rtype: int
|
|
|
|
%End
|
[FEATURE] Aggregates for expressions
This commit adds a number of different forms of aggregates to
the expression engine.
1. Aggregates within the current layer, eg sum("passengers")
Supports sub expressions (ie sum("passengers"/2) ), group by
( sum("passengers", group_by:="line_segment") ), and optional
filters ( sum("passengers", filter:= "station_class" > 3 ) )
2. Relational aggregates, which calculate an aggregate over
all matching child features from a relation, eg
relation_aggregate( 'my_relation', 'mean', "some_child_field" )
3. A summary aggregate function, for calculating aggregates
on other layers. Eg aggregate('rail_station_layer','sum',"passengers")
The summary aggregate function supports an optional filter,
making it possible to calculate things like:
aggregate('rail_stations','sum',"passengers",
intersects(@atlas_geometry, $geometry ) )
for calculating the total number of passengers for the stations
inside the current atlas feature
In all cases the calculations are cached inside the expression
context, so they only need to be calculated once for each
set of expression evaluations.
Sponsored by Kanton of Zug, Switzerland
2016-05-16 17:30:07 +10:00
|
|
|
|
2015-05-02 23:19:39 +10:00
|
|
|
double sum() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated sum of values
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double mean() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated mean of values. A NaN value may be returned if the mean cannot
|
|
|
|
be calculated.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double median() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated median of values. This is only calculated if Statistic.Median has
|
|
|
|
been specified in the constructor or via setStatistics. A NaN value may be returned if the median cannot
|
|
|
|
be calculated.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double min() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated minimum from values. A NaN value may be returned if the minimum cannot
|
|
|
|
be calculated.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double max() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated maximum from values. A NaN value may be returned if the maximum cannot
|
|
|
|
be calculated.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double range() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns calculated range (difference between maximum and minimum values). A NaN value may be returned if the range cannot
|
|
|
|
be calculated.
|
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double stDev() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns population standard deviation. This is only calculated if Statistic.StDev has
|
|
|
|
been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`sampleStDev`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double sampleStDev() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns sample standard deviation. This is only calculated if Statistic.StDev has
|
|
|
|
been specified in the constructor or via setStatistics. A NaN value may be returned if the standard deviation cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`stDev`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
int variety() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns variety of values. The variety is the count of unique values from the list.
|
|
|
|
This is only calculated if Statistic.Variety has been specified in the constructor
|
|
|
|
or via setStatistics.
|
|
|
|
:rtype: int
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double minority() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns minority of values. The minority is the value with least occurrences in the list
|
|
|
|
This is only calculated if Statistic.Minority has been specified in the constructor
|
|
|
|
or via setStatistics. A NaN value may be returned if the minority cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`majority`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
|
|
|
double majority() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns majority of values. The majority is the value with most occurrences in the list
|
|
|
|
This is only calculated if Statistic.Majority has been specified in the constructor
|
|
|
|
or via setStatistics. A NaN value may be returned if the majority cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`minority`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-03 17:10:32 +02:00
|
|
|
|
2015-05-03 20:48:22 +10:00
|
|
|
double firstQuartile() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns the first quartile of the values. The quartile is calculated using the
|
|
|
|
"Tukey's hinges" method. A NaN value may be returned if the first quartile cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`thirdQuartile`
|
|
|
|
.. seealso:: :py:func:`interQuartileRange`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-03 20:48:22 +10:00
|
|
|
|
|
|
|
double thirdQuartile() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns the third quartile of the values. The quartile is calculated using the
|
|
|
|
"Tukey's hinges" method. A NaN value may be returned if the third quartile cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`firstQuartile`
|
|
|
|
.. seealso:: :py:func:`interQuartileRange`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-03 20:48:22 +10:00
|
|
|
|
|
|
|
double interQuartileRange() const;
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns the inter quartile range of the values. The quartiles are calculated using the
|
|
|
|
"Tukey's hinges" method. A NaN value may be returned if the IQR cannot
|
|
|
|
be calculated.
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`firstQuartile`
|
|
|
|
.. seealso:: :py:func:`thirdQuartile`
|
2017-05-01 12:15:01 +03:00
|
|
|
:rtype: float
|
|
|
|
%End
|
2015-05-02 23:19:39 +10:00
|
|
|
|
2017-05-01 12:53:35 +03:00
|
|
|
static QString displayName( QgsStatisticalSummary::Statistic statistic );
|
2017-05-01 12:15:01 +03:00
|
|
|
%Docstring
|
|
|
|
Returns the friendly display name for a statistic
|
|
|
|
\param statistic statistic to return name for
|
|
|
|
:rtype: str
|
|
|
|
%End
|
2015-05-18 05:55:14 +10:00
|
|
|
|
2015-05-02 23:19:39 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
QFlags<QgsStatisticalSummary::Statistic> operator|(QgsStatisticalSummary::Statistic f1, QFlags<QgsStatisticalSummary::Statistic> f2);
|
|
|
|
|
2017-05-01 12:15:01 +03:00
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsstatisticalsummary.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|