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(),
158 static QMap<QgsZonalStatistics::Statistic, QVariant> calculateStatistics(
QgsRasterInterface *rasterInterface,
const QgsGeometry &geometry,
double cellSizeX,
double cellSizeY,
int rasterBand, QgsZonalStatistics::Statistics statistics );
166 FeatureStats(
bool storeValues =
false,
bool storeValueCounts =
false )
167 : mStoreValues( storeValues )
168 , mStoreValueCounts( storeValueCounts )
176 max = std::numeric_limits<double>::lowest();
177 min = std::numeric_limits<double>::max();
182 void addValue(
double value,
double weight = 1.0 )
186 sum += value * weight;
194 min = std::min( min, value );
195 max = std::max( max, value );
196 if ( mStoreValueCounts )
197 valueCount.insert( value, valueCount.value( value, 0 ) + 1 );
199 values.append( value );
203 double max = std::numeric_limits<double>::lowest();
204 double min = std::numeric_limits<double>::max();
205 QMap< double, int > valueCount;
206 QList< double > values;
209 bool mStoreValues =
false;
210 bool mStoreValueCounts =
false;
213 QString getUniqueFieldName(
const QString &fieldName,
const QList<QgsField> &newFields );
218 double mCellSizeX = 0;
219 double mCellSizeY = 0;
224 QString mAttributePrefix;
232 #endif // QGSZONALSTATISTICS_H