QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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, All = Count | Sum | Mean | Median | StDev | Max | Min | Range | Minority | Majority | Variety
}
 Enumeration of flags that specify statistics to be calculated. More...
 

Public Member Functions

 QgsZonalStatistics (QgsVectorLayer *polygonLayer, const QString &rasterFile, const QString &attributePrefix="", int rasterBand=1, const Statistics &stats=Statistics(Count|Sum|Mean))
 
int calculateStatistics (QProgressDialog *p)
 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 30 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.

All 

Definition at line 35 of file qgszonalstatistics.h.

Constructor & Destructor Documentation

◆ QgsZonalStatistics()

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

Definition at line 34 of file qgszonalstatistics.cpp.

Member Function Documentation

◆ calculateStatistics()

int QgsZonalStatistics::calculateStatistics ( QProgressDialog p)

Starts the calculation.

Returns
0 in case of success

Definition at line 54 of file qgszonalstatistics.cpp.


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