18 #ifndef QGSZONALSTATISTICS_H 19 #define QGSZONALSTATISTICS_H 27 #include "qgis_analysis.h" 59 All = Count | Sum | Mean | Median | StDev | Max | Min | Range | Minority | Majority | Variety | Variance
68 const QString &attributePrefix = QString(),
83 FeatureStats(
bool storeValues =
false,
bool storeValueCounts =
false )
84 : mStoreValues( storeValues )
85 , mStoreValueCounts( storeValueCounts )
89 void reset() { sum = 0; count = 0; max = -FLT_MAX; min = FLT_MAX; valueCount.clear(); values.clear(); }
90 void addValue(
float value,
double weight = 1.0 )
94 sum += value * weight;
102 min = std::min( min, value );
103 max = std::max( max, value );
104 if ( mStoreValueCounts )
105 valueCount.insert( value, valueCount.value( value, 0 ) + 1 );
107 values.append( value );
113 QMap< float, int > valueCount;
114 QList< float > values;
118 bool mStoreValueCounts;
124 int cellInfoForBBox(
const QgsRectangle &rasterBBox,
const QgsRectangle &featureBBox,
double cellSizeX,
double cellSizeY,
125 int &offsetX,
int &offsetY,
int &nCellsX,
int &nCellsY )
const;
128 void statisticsFromMiddlePointTest(
const QgsGeometry &poly,
int pixelOffsetX,
int pixelOffsetY,
int nCellsX,
int nCellsY,
129 double cellSizeX,
double cellSizeY,
const QgsRectangle &rasterBBox, FeatureStats &stats );
132 void statisticsFromPreciseIntersection(
const QgsGeometry &poly,
int pixelOffsetX,
int pixelOffsetY,
int nCellsX,
int nCellsY,
133 double cellSizeX,
double cellSizeY,
const QgsRectangle &rasterBBox, FeatureStats &stats );
136 bool validPixel(
float value )
const;
138 QString getUniqueFieldName(
const QString &fieldName,
const QList<QgsField> &newFields );
145 QString mAttributePrefix;
147 float mInputNodataValue = -1;
151 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsZonalStatistics::Statistics )
155 #endif // QGSZONALSTATISTICS_H
A rectangle specified with double values.
Statistic
Enumeration of flags that specify statistics to be calculated.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
A geometry is the spatial representation of a feature.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Encapsulate a field in an attribute table or data source.
A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and ...
Represents a vector layer which manages a vector based data sets.
Base class for raster data providers.