Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgszonalstatistics.h - description 00003 ---------------------------- 00004 begin : August 29th, 2009 00005 copyright : (C) 2009 by Marco Hugentobler 00006 email : marco at hugis dot net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 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