| QGIS API Documentation
    2.2.0-Valmiera
    | 
A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and appends the results as attributes. More...
#include <qgszonalstatistics.h>

| Public Member Functions | |
| QgsZonalStatistics (QgsVectorLayer *polygonLayer, const QString &rasterFile, const QString &attributePrefix="", int rasterBand=1) | |
| ~QgsZonalStatistics () | |
| int | calculateStatistics (QProgressDialog *p) | 
| Starts the calculation. | |
| Private Member Functions | |
| QgsZonalStatistics () | |
| int | cellInfoForBBox (const QgsRectangle &rasterBBox, const QgsRectangle &featureBBox, double cellSizeX, double cellSizeY, int &offsetX, int &offsetY, int &nCellsX, int &nCellsY) const | 
| Analysis what cells need to be considered to cover the bounding box of a feature. | |
| void | statisticsFromMiddlePointTest (void *band, QgsGeometry *poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, double &sum, double &count) | 
| Returns statistics by considering the pixels where the center point is within the polygon (fast) | |
| void | statisticsFromMiddlePointTest_improved (void *band, QgsGeometry *poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, double &sum, double &count) | 
| void | statisticsFromPreciseIntersection (void *band, QgsGeometry *poly, int pixelOffsetX, int pixelOffsetY, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, double &sum, double &count) | 
| Returns statistics with precise pixel - polygon intersection test (slow) | |
| QString | getUniqueFieldName (QString fieldName) | 
| Private Attributes | |
| QString | mRasterFilePath | 
| int | mRasterBand | 
| Raster band to calculate statistics from (defaults to 1) | |
| QgsVectorLayer * | mPolygonLayer | 
| QString | mAttributePrefix | 
| float | mInputNodataValue | 
| The nodata value of the input layer. | |
A class that calculates raster statistics (count, sum, mean) for a polygon or multipolygon layer and appends the results as attributes.
Definition at line 29 of file qgszonalstatistics.h.
| QgsZonalStatistics::QgsZonalStatistics | ( | QgsVectorLayer * | polygonLayer, | 
| const QString & | rasterFile, | ||
| const QString & | attributePrefix = "", | ||
| int | rasterBand = 1 | ||
| ) | 
Definition at line 33 of file qgszonalstatistics.cpp.
| QgsZonalStatistics::~QgsZonalStatistics | ( | ) | 
Definition at line 50 of file qgszonalstatistics.cpp.
| 
 | private | 
Definition at line 43 of file qgszonalstatistics.cpp.
| int QgsZonalStatistics::calculateStatistics | ( | QProgressDialog * | p | ) | 
Starts the calculation.
Definition at line 55 of file qgszonalstatistics.cpp.
References QgsVectorDataProvider::addAttributes(), QgsGeometry::boundingBox(), cellInfoForBBox(), QgsVectorDataProvider::changeAttributeValues(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::featureCount(), QgsVectorDataProvider::fieldNameIndex(), QgsFeature::geometry(), QgsVectorLayer::geometryType(), QgsVectorDataProvider::getFeatures(), getUniqueFieldName(), QgsFeature::id(), QgsRectangle::intersect(), QgsRectangle::isEmpty(), mAttributePrefix, mInputNodataValue, mPolygonLayer, mRasterBand, mRasterFilePath, QgsFeatureIterator::nextFeature(), QGis::Polygon, QgsFeatureRequest::setSubsetOfAttributes(), statisticsFromMiddlePointTest(), statisticsFromPreciseIntersection(), TO8F, and QgsVectorLayer::updateFields().
| 
 | private | 
Analysis what cells need to be considered to cover the bounding box of a feature.
Definition at line 244 of file qgszonalstatistics.cpp.
References QgsRectangle::intersect(), QgsRectangle::isEmpty(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by calculateStatistics().
| 
 | private | 
Definition at line 372 of file qgszonalstatistics.cpp.
References QgsFields::count(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::fields(), mPolygonLayer, and QgsVectorDataProvider::storageType().
Referenced by calculateStatistics().
| 
 | private | 
Returns statistics by considering the pixels where the center point is within the polygon (fast)
Definition at line 268 of file qgszonalstatistics.cpp.
References QgsGeometry::asGeos(), mInputNodataValue, QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by calculateStatistics().
| 
 | private | 
| 
 | private | 
Returns statistics with precise pixel - polygon intersection test (slow)
Definition at line 328 of file qgszonalstatistics.cpp.
References QgsGeometry::area(), QgsGeometry::fromRect(), QgsGeometry::intersection(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by calculateStatistics().
| 
 | private | 
Definition at line 63 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
| 
 | private | 
The nodata value of the input layer.
Definition at line 65 of file qgszonalstatistics.h.
Referenced by calculateStatistics(), and statisticsFromMiddlePointTest().
| 
 | private | 
Definition at line 62 of file qgszonalstatistics.h.
Referenced by calculateStatistics(), and getUniqueFieldName().
| 
 | private | 
Raster band to calculate statistics from (defaults to 1)
Definition at line 61 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
| 
 | private | 
Definition at line 59 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
 1.8.1.2
 1.8.1.2