2011-09-28 14:44:28 +03:00
|
|
|
/** \ingroup analysis
|
|
|
|
* The QGis class that calculates raster statistics (count, sum, mean) for
|
|
|
|
* a polygon or multipolygon layer and appends the results as attributes
|
|
|
|
*/
|
|
|
|
|
|
|
|
class QgsZonalStatistics
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgszonalstatistics.h>
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
2015-04-20 18:20:02 +10:00
|
|
|
|
|
|
|
//! Enumeration of flags that specify statistics to be calculated
|
|
|
|
enum Statistic
|
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QFlags<QgsZonalStatistics::Statistic> Statistics;
|
|
|
|
|
|
|
|
QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix = "", int rasterBand = 1,
|
2015-10-07 11:55:34 +11:00
|
|
|
const QgsZonalStatistics::Statistics& stats = QgsZonalStatistics::Statistics( QgsZonalStatistics::Count | QgsZonalStatistics::Sum | QgsZonalStatistics::Mean) );
|
2011-09-28 14:44:28 +03:00
|
|
|
~QgsZonalStatistics();
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Starts the calculation
|
2011-09-28 14:44:28 +03:00
|
|
|
@return 0 in case of success*/
|
|
|
|
int calculateStatistics( QProgressDialog* p );
|
|
|
|
};
|
2015-04-20 18:20:02 +10:00
|
|
|
|
|
|
|
QFlags<QgsZonalStatistics::Statistic> operator|(QgsZonalStatistics::Statistic f1, QFlags<QgsZonalStatistics::Statistic> f2);
|
|
|
|
|