18 #ifndef QGSZONALSTATISTICS_H
19 #define QGSZONALSTATISTICS_H
27 #include "qgis_analysis.h"
65 All = Count | Sum | Mean | Median | StDev | Max | Min | Range | Minority | Majority | Variety | Variance
67 Q_DECLARE_FLAGS( Statistics, Statistic )
77 FailedToCreateField = 8,
91 const QString &attributePrefix = QString(),
124 double rasterUnitsPerPixelX,
125 double rasterUnitsPerPixelY,
126 const QString &attributePrefix = QString(),
159 static QMap<QgsZonalStatistics::Statistic, QVariant> calculateStatistics(
QgsRasterInterface *rasterInterface,
const QgsGeometry &geometry,
double cellSizeX,
double cellSizeY,
int rasterBand, QgsZonalStatistics::Statistics statistics );
173 static QMap<int, QVariant> calculateStatisticsInt(
QgsRasterInterface *rasterInterface,
const QgsGeometry &geometry,
double cellSizeX,
double cellSizeY,
int rasterBand, QgsZonalStatistics::Statistics statistics )
SIP_PYNAME( calculateStatistics );
182 FeatureStats(
bool storeValues =
false,
bool storeValueCounts =
false )
183 : mStoreValues( storeValues )
184 , mStoreValueCounts( storeValueCounts )
192 max = std::numeric_limits<double>::lowest();
193 min = std::numeric_limits<double>::max();
198 void addValue(
double value,
double weight = 1.0 )
202 sum += value * weight;
210 min = std::min( min, value );
211 max = std::max( max, value );
212 if ( mStoreValueCounts )
213 valueCount.insert( value, valueCount.value( value, 0 ) + 1 );
215 values.append( value );
219 double max = std::numeric_limits<double>::lowest();
220 double min = std::numeric_limits<double>::max();
221 QMap< double, int > valueCount;
222 QList< double > values;
225 bool mStoreValues =
false;
226 bool mStoreValueCounts =
false;
229 QString getUniqueFieldName(
const QString &fieldName,
const QList<QgsField> &newFields );
234 double mCellSizeX = 0;
235 double mCellSizeY = 0;
240 QString mAttributePrefix;
248 #endif // QGSZONALSTATISTICS_H