Quantum GIS API Documentation
1.7.5-Wroclaw
|
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. More... | |
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. More... | |
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) More... | |
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) More... | |
Private Attributes | |
QString | mRasterFilePath |
int | mRasterBand |
Raster band to calculate statistics from (defaults to 1) More... | |
QgsVectorLayer * | mPolygonLayer |
QString | mAttributePrefix |
float | mInputNodataValue |
The nodata value of the input layer. More... | |
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 32 of file qgszonalstatistics.cpp.
QgsZonalStatistics::~QgsZonalStatistics | ( | ) |
Definition at line 49 of file qgszonalstatistics.cpp.
|
private |
Definition at line 42 of file qgszonalstatistics.cpp.
int QgsZonalStatistics::calculateStatistics | ( | QProgressDialog * | p) |
Starts the calculation.
Definition at line 54 of file qgszonalstatistics.cpp.
References QgsVectorDataProvider::addAttributes(), QgsGeometry::boundingBox(), cellInfoForBBox(), QgsVectorDataProvider::changeAttributeValues(), QgsVectorLayer::dataProvider(), QgsVectorDataProvider::featureCount(), QgsVectorDataProvider::fieldNameIndex(), QgsFeature::geometry(), QgsVectorLayer::geometryType(), QgsFeature::id(), mAttributePrefix, mInputNodataValue, mPolygonLayer, mRasterBand, mRasterFilePath, QgsVectorDataProvider::nextFeature(), QGis::Polygon, QgsVectorDataProvider::select(), statisticsFromMiddlePointTest_improved(), statisticsFromPreciseIntersection(), TO8, and QgsVectorLayer::updateFieldMap().
|
private |
Analysis what cells need to be considered to cover the bounding box of a feature.
Definition at line 221 of file qgszonalstatistics.cpp.
References QgsRectangle::intersect(), QgsRectangle::isEmpty(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by calculateStatistics().
|
private |
Returns statistics by considering the pixels where the center point is within the polygon (fast)
Definition at line 245 of file qgszonalstatistics.cpp.
References QgsGeometry::contains(), mInputNodataValue, QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
|
private |
Definition at line 322 of file qgszonalstatistics.cpp.
References QgsGeometry::asGeos(), mInputNodataValue, QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by calculateStatistics().
|
private |
Returns statistics with precise pixel - polygon intersection test (slow)
Definition at line 278 of file qgszonalstatistics.cpp.
References QgsGeometry::area(), QgsGeometry::fromRect(), QgsGeometry::intersection(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by calculateStatistics().
|
private |
Definition at line 62 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
|
private |
The nodata value of the input layer.
Definition at line 64 of file qgszonalstatistics.h.
Referenced by calculateStatistics(), statisticsFromMiddlePointTest(), and statisticsFromMiddlePointTest_improved().
|
private |
Definition at line 61 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
|
private |
Raster band to calculate statistics from (defaults to 1)
Definition at line 60 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
|
private |
Definition at line 58 of file qgszonalstatistics.h.
Referenced by calculateStatistics().