#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). | |
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. |
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.
QgsZonalStatistics::QgsZonalStatistics | ( | ) | [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::rewind(), QgsVectorDataProvider::select(), statisticsFromMiddlePointTest_improved(), statisticsFromPreciseIntersection(), and TO8.
int QgsZonalStatistics::cellInfoForBBox | ( | const QgsRectangle & | rasterBBox, | |
const QgsRectangle & | featureBBox, | |||
double | cellSizeX, | |||
double | cellSizeY, | |||
int & | offsetX, | |||
int & | offsetY, | |||
int & | nCellsX, | |||
int & | nCellsY | |||
) | const [private] |
Analysis what cells need to be considered to cover the bounding box of a feature.
Definition at line 218 of file qgszonalstatistics.cpp.
References QgsRectangle::intersect(), QgsRectangle::isEmpty(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by calculateStatistics().
void QgsZonalStatistics::statisticsFromMiddlePointTest | ( | void * | band, | |
QgsGeometry * | poly, | |||
int | pixelOffsetX, | |||
int | pixelOffsetY, | |||
int | nCellsX, | |||
int | nCellsY, | |||
double | cellSizeX, | |||
double | cellSizeY, | |||
const QgsRectangle & | rasterBBox, | |||
double & | sum, | |||
double & | count | |||
) | [private] |
Returns statistics by considering the pixels where the center point is within the polygon (fast).
Definition at line 242 of file qgszonalstatistics.cpp.
References QgsGeometry::contains(), mInputNodataValue, QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
void QgsZonalStatistics::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 | |||
) | [private] |
Definition at line 319 of file qgszonalstatistics.cpp.
References QgsGeometry::asGeos(), mInputNodataValue, QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by calculateStatistics().
void QgsZonalStatistics::statisticsFromPreciseIntersection | ( | void * | band, | |
QgsGeometry * | poly, | |||
int | pixelOffsetX, | |||
int | pixelOffsetY, | |||
int | nCellsX, | |||
int | nCellsY, | |||
double | cellSizeX, | |||
double | cellSizeY, | |||
const QgsRectangle & | rasterBBox, | |||
double & | sum, | |||
double & | count | |||
) | [private] |
Returns statistics with precise pixel - polygon intersection test (slow).
Definition at line 275 of file qgszonalstatistics.cpp.
References QgsGeometry::area(), QgsGeometry::fromRect(), QgsGeometry::intersection(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().
Referenced by calculateStatistics().
QString QgsZonalStatistics::mRasterFilePath [private] |
int QgsZonalStatistics::mRasterBand [private] |
Raster band to calculate statistics from (defaults to 1).
Definition at line 60 of file qgszonalstatistics.h.
Referenced by calculateStatistics().
QgsVectorLayer* QgsZonalStatistics::mPolygonLayer [private] |
QString QgsZonalStatistics::mAttributePrefix [private] |
float QgsZonalStatistics::mInputNodataValue [private] |
The nodata value of the input layer.
Definition at line 64 of file qgszonalstatistics.h.
Referenced by calculateStatistics(), statisticsFromMiddlePointTest(), and statisticsFromMiddlePointTest_improved().