QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QgsRasterCalculator Class Reference

Raster calculator class. More...

#include <qgsrastercalculator.h>

Collaboration diagram for QgsRasterCalculator:
Collaboration graph
[legend]

Public Member Functions

 QgsRasterCalculator (const QString &formulaString, const QString &outputFile, const QString &outputFormat, const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector< QgsRasterCalculatorEntry > &rasterEntries)
 ~QgsRasterCalculator ()
int processCalculation (QProgressDialog *p=0)
 Starts the calculation and writes new raster.

Private Member Functions

 QgsRasterCalculator ()
GDALDriverH openOutputDriver ()
 Opens the output driver and tests if it supports the creation of a new dataset.
GDALDatasetH openOutputFile (GDALDriverH outputDriver)
 Opens the output file and sets the same geotransform and CRS as the input data.
void readRasterPart (double *targetGeotransform, int xOffset, int yOffset, int nCols, int nRows, double *sourceTransform, GDALRasterBandH sourceBand, float *rasterBuffer)
 Reads raster pixels from a dataset/band.
bool transformationsEqual (double *t1, double *t2) const
 Compares two geotransformations (six parameter double arrays.
void outputGeoTransform (double *transform) const
 Sets gdal 6 parameters array from mOutputRectangle, mNumOutputColumns, mNumOutputRows.

Private Attributes

QString mFormulaString
QString mOutputFile
QString mOutputFormat
QgsRectangle mOutputRectangle
 Output raster extent.
int mNumOutputColumns
 Number of output columns.
int mNumOutputRows
 Number of output rows.
QVector< QgsRasterCalculatorEntrymRasterEntries

Detailed Description

Raster calculator class.

Definition at line 39 of file qgsrastercalculator.h.

Constructor & Destructor Documentation

QgsRasterCalculator::QgsRasterCalculator ( const QString &  formulaString,
const QString &  outputFile,
const QString &  outputFormat,
const QgsRectangle outputExtent,
int  nOutputColumns,
int  nOutputRows,
const QVector< QgsRasterCalculatorEntry > &  rasterEntries 
)

Definition at line 37 of file qgsrastercalculator.cpp.

QgsRasterCalculator::~QgsRasterCalculator ( )

Definition at line 43 of file qgsrastercalculator.cpp.

QgsRasterCalculator::QgsRasterCalculator ( )
private

Definition at line 252 of file qgsrastercalculator.cpp.

Member Function Documentation

GDALDriverH QgsRasterCalculator::openOutputDriver ( )
private

Opens the output driver and tests if it supports the creation of a new dataset.

Returns
NULL on error and the driver handle on success

Definition at line 256 of file qgsrastercalculator.cpp.

References mOutputFormat.

Referenced by processCalculation().

GDALDatasetH QgsRasterCalculator::openOutputFile ( GDALDriverH  outputDriver)
private

Opens the output file and sets the same geotransform and CRS as the input data.

Returns
the output dataset or NULL in case of error

Definition at line 277 of file qgsrastercalculator.cpp.

References mNumOutputColumns, mNumOutputRows, mOutputFile, outputGeoTransform(), and TO8F.

Referenced by processCalculation().

void QgsRasterCalculator::outputGeoTransform ( double *  transform) const
private

Sets gdal 6 parameters array from mOutputRectangle, mNumOutputColumns, mNumOutputRows.

Parameters
transformdouble[6] array that receives the GDAL parameters

Definition at line 404 of file qgsrastercalculator.cpp.

References QgsRectangle::height(), mNumOutputColumns, mNumOutputRows, mOutputRectangle, QgsRectangle::width(), QgsRectangle::xMinimum(), and QgsRectangle::yMaximum().

Referenced by openOutputFile(), and processCalculation().

int QgsRasterCalculator::processCalculation ( QProgressDialog *  p = 0)
void QgsRasterCalculator::readRasterPart ( double *  targetGeotransform,
int  xOffset,
int  yOffset,
int  nCols,
int  nRows,
double *  sourceTransform,
GDALRasterBandH  sourceBand,
float *  rasterBuffer 
)
private

Reads raster pixels from a dataset/band.

Parameters
targetGeotransformtransformation parameters of the requested raster array (not necessarily the same as the transform of the source dataset)
xOffsetx offset
yOffsety offset
nColsnumber of columns
nRowsnumber of rows
sourceTransformsource transformation
sourceBandsource band
rasterBufferraster buffer

Definition at line 295 of file qgsrastercalculator.cpp.

References QgsRectangle::intersect(), QgsRectangle::isEmpty(), transformationsEqual(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().

Referenced by processCalculation().

bool QgsRasterCalculator::transformationsEqual ( double *  t1,
double *  t2 
) const
private

Compares two geotransformations (six parameter double arrays.

Definition at line 392 of file qgsrastercalculator.cpp.

References qgsDoubleNear().

Referenced by readRasterPart().

Member Data Documentation

QString QgsRasterCalculator::mFormulaString
private

Definition at line 88 of file qgsrastercalculator.h.

Referenced by processCalculation().

int QgsRasterCalculator::mNumOutputColumns
private

Number of output columns.

Definition at line 95 of file qgsrastercalculator.h.

Referenced by openOutputFile(), outputGeoTransform(), and processCalculation().

int QgsRasterCalculator::mNumOutputRows
private

Number of output rows.

Definition at line 97 of file qgsrastercalculator.h.

Referenced by openOutputFile(), outputGeoTransform(), and processCalculation().

QString QgsRasterCalculator::mOutputFile
private

Definition at line 89 of file qgsrastercalculator.h.

Referenced by openOutputFile(), and processCalculation().

QString QgsRasterCalculator::mOutputFormat
private

Definition at line 90 of file qgsrastercalculator.h.

Referenced by openOutputDriver().

QgsRectangle QgsRasterCalculator::mOutputRectangle
private

Output raster extent.

Definition at line 93 of file qgsrastercalculator.h.

Referenced by outputGeoTransform().

QVector<QgsRasterCalculatorEntry> QgsRasterCalculator::mRasterEntries
private

Definition at line 100 of file qgsrastercalculator.h.

Referenced by processCalculation().


The documentation for this class was generated from the following files: