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;
 
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.