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;
This class represents a coordinate reference system (CRS).
An interface for objects which accept features via addFeature(s) methods.
An interface for objects which provide features via a getFeatures method.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Encapsulate a field in an attribute table or data source.
A geometry is the spatial representation of a feature.
Base class for raster data providers.
Base class for processing filters like renderers, reprojector, resampler etc.
Represents a raster layer.
A rectangle specified with double values.
Represents a vector layer which manages a vector based data sets.
A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and ...
Statistic
Enumeration of flags that specify statistics to be calculated.
@ Mean
Mean of pixel values.
@ Sum
Sum of pixel values.
Result
Error codes for calculation.
@ RasterInvalid
Raster layer is invalid.
@ RasterBandInvalid
The raster band does not exist on the raster layer.
@ LayerInvalid
Layer is invalid.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.