QGIS API Documentation  3.0.2-Girona (307d082)
Classes | Public Types | Public Member Functions | List of all members
QgsZonalStatistics Class Reference

A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and appends the results as attributes. More...

#include <qgszonalstatistics.h>

Public Types

enum  Statistic {
  Count = 1, Sum = 2, Mean = 4, Median = 8,
  StDev = 16, Min = 32, Max = 64, Range = 128,
  Minority = 256, Majority = 512, Variety = 1024, Variance = 2048,
  All = Count | Sum | Mean | Median | StDev | Max | Min | Range | Minority | Majority | Variety | Variance
}
 Enumeration of flags that specify statistics to be calculated. More...
 

Public Member Functions

 QgsZonalStatistics (QgsVectorLayer *polygonLayer, QgsRasterLayer *rasterLayer, const QString &attributePrefix=QString(), int rasterBand=1, QgsZonalStatistics::Statistics stats=QgsZonalStatistics::Statistics(QgsZonalStatistics::Count|QgsZonalStatistics::Sum|QgsZonalStatistics::Mean))
 Constructor for QgsZonalStatistics. More...
 
int calculateStatistics (QgsFeedback *feedback)
 Starts the calculation. More...
 

Detailed Description

A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and appends the results as attributes.

Definition at line 40 of file qgszonalstatistics.h.

Member Enumeration Documentation

◆ Statistic

Enumeration of flags that specify statistics to be calculated.

Enumerator
Count 

Pixel count.

Sum 

Sum of pixel values.

Mean 

Mean of pixel values.

Median 

Median of pixel values.

StDev 

Standard deviation of pixel values.

Min 

Min of pixel values.

Max 

Max of pixel values.

Range 

Range of pixel values (max - min)

Minority 

Minority of pixel values.

Majority 

Majority of pixel values.

Variety 

Variety (count of distinct) pixel values.

Variance 

Variance of pixel values.

All 

Definition at line 45 of file qgszonalstatistics.h.

Constructor & Destructor Documentation

◆ QgsZonalStatistics()

QgsZonalStatistics::QgsZonalStatistics ( QgsVectorLayer polygonLayer,
QgsRasterLayer rasterLayer,
const QString &  attributePrefix = QString(),
int  rasterBand = 1,
QgsZonalStatistics::Statistics  stats = QgsZonalStatistics::Statistics( QgsZonalStatistics::Count | QgsZonalStatistics::Sum | QgsZonalStatistics::Mean ) 
)

Constructor for QgsZonalStatistics.

Definition at line 32 of file qgszonalstatistics.cpp.

Member Function Documentation

◆ calculateStatistics()

int QgsZonalStatistics::calculateStatistics ( QgsFeedback feedback)

Starts the calculation.

Returns
0 in case of success

Definition at line 40 of file qgszonalstatistics.cpp.


The documentation for this class was generated from the following files: