QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgszonalstatistics.h
Go to the documentation of this file.
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  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
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. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSZONALSTATISTICS_H
19 #define QGSZONALSTATISTICS_H
20 
21 #include "qgsrectangle.h"
22 #include <QString>
23 
24 class QgsGeometry;
25 class QgsVectorLayer;
26 class QProgressDialog;
27 
29 class ANALYSIS_EXPORT QgsZonalStatistics
30 {
31  public:
32  QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix = "", int rasterBand = 1 );
34 
37  int calculateStatistics( QProgressDialog* p );
38 
39  private:
43  int cellInfoForBBox( const QgsRectangle& rasterBBox, const QgsRectangle& featureBBox, double cellSizeX, double cellSizeY,
44  int& offsetX, int& offsetY, int& nCellsX, int& nCellsY ) const;
45 
47  void statisticsFromMiddlePointTest( void* band, QgsGeometry* poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
48  double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, double& sum, double& count );
49 
50  void statisticsFromMiddlePointTest_improved( void* band, QgsGeometry* poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
51  double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, double& sum, double& count );
52 
54  void statisticsFromPreciseIntersection( void* band, QgsGeometry* poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY,
55  double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, double& sum, double& count );
56 
58  bool validPixel( float value ) const;
59 
60  QString getUniqueFieldName( QString fieldName );
61 
62  QString mRasterFilePath;
64  int mRasterBand;
65  QgsVectorLayer* mPolygonLayer;
66  QString mAttributePrefix;
68  float mInputNodataValue;
69 
70 };
71 
72 #endif // QGSZONALSTATISTICS_H