00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef QGSZONALSTATISTICS_H
00019 #define QGSZONALSTATISTICS_H
00020
00021 #include "qgsrectangle.h"
00022 #include <QString>
00023
00024 class QgsGeometry;
00025 class QgsVectorLayer;
00026 class QProgressDialog;
00027
00029 class ANALYSIS_EXPORT QgsZonalStatistics
00030 {
00031 public:
00032 QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix = "", int rasterBand = 1 );
00033 ~QgsZonalStatistics();
00034
00037 int calculateStatistics( QProgressDialog* p );
00038
00039 private:
00040 QgsZonalStatistics();
00043 int cellInfoForBBox( const QgsRectangle& rasterBBox, const QgsRectangle& featureBBox, double cellSizeX, double cellSizeY,
00044 int& offsetX, int& offsetY, int& nCellsX, int& nCellsY ) const;
00045
00047 void statisticsFromMiddlePointTest( void* band, QgsGeometry* poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY, \
00048 double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, double& sum, double& count );
00049
00050 void statisticsFromMiddlePointTest_improved( void* band, QgsGeometry* poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY, \
00051 double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, double& sum, double& count );
00052
00054 void statisticsFromPreciseIntersection( void* band, QgsGeometry* poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY, \
00055 double cellSizeX, double cellSizeY, const QgsRectangle& rasterBBox, double& sum, double& count );
00056
00057
00058 QString mRasterFilePath;
00060 int mRasterBand;
00061 QgsVectorLayer* mPolygonLayer;
00062 QString mAttributePrefix;
00064 float mInputNodataValue;
00065 };
00066
00067 #endif // QGSZONALSTATISTICS_H