1
/***************************************************************************
2
qgszonalstatistics.h - description
3
----------------------------
4
begin : August 29th, 2009
5
copyright : (C) 2009 by Marco Hugentobler
6
email : marco at hugis dot net
7
***************************************************************************/
9
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
***************************************************************************/
18
#ifndef QGSZONALSTATISTICS_H
19
#define QGSZONALSTATISTICS_H
21
#include "qgsrectangle.h"
25
class QProgressDialog;
27
/**A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and appends the results as attributes*/
28
class ANALYSIS_EXPORT QgsZonalStatistics
31
QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix = "", int rasterBand = 1 );
32
~QgsZonalStatistics();
34
/**Starts the calculation
35
@return 0 in case of success*/
36
int calculateStatistics( QProgressDialog* p );
40
/**Analysis what cells need to be considered to cover the bounding box of a feature
41
@return 0 in case of success*/
42
int cellInfoForBBox( const QgsRectangle& rasterBBox, const QgsRectangle& featureBBox, double cellSizeX, double cellSizeY,
43
int& offsetX, int& offsetY, int& nCellsX, int& nCellsY ) const;
45
QString mRasterFilePath;
46
/**Raster band to calculate statistics from (defaults to 1)*/
48
QgsVectorLayer* mPolygonLayer;
49
QString mAttributePrefix;
50
/**The nodata value of the input layer*/
51
float mInputNodataValue;
54
#endif // QGSZONALSTATISTICS_H