QGIS API Documentation  2.0.1-Dufour
 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 
57  QString getUniqueFieldName( QString fieldName );
58 
59  QString mRasterFilePath;
66 };
67 
68 #endif // QGSZONALSTATISTICS_H