QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsrastercalculator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrastercalculator.h - description
3 ---------------------
4 begin : September 28th, 2010
5 copyright : (C) 2010 by Marco Hugentobler
6 email : marco dot hugentobler at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSRASTERCALCULATOR_H
19#define QGSRASTERCALCULATOR_H
20
21#include "qgsrectangle.h"
24#include <QString>
25#include <QVector>
26#include "gdal.h"
27#include "qgis_analysis.h"
28#include "qgsogrutils.h"
29#include "qgsrastercalcnode.h"
30
31class QgsRasterLayer;
32class QgsFeedback;
33
39class ANALYSIS_EXPORT QgsRasterCalculatorEntry
40{
41 public:
52 static QVector<QgsRasterCalculatorEntry> rasterEntries();
53
57 QString ref;
58
62 QgsRasterLayer *raster = nullptr;
63
67 int bandNumber = 1;
68};
69
74class ANALYSIS_EXPORT QgsRasterCalculator
75{
76 public:
78 enum Result
79 {
80 Success = 0,
81 CreateOutputError = 1,
82 InputLayerError = 2,
83 Canceled = 3,
84 ParserError = 4,
85 MemoryError = 5,
86 BandError = 6,
87 CalculationError = 7,
88 };
89
90
103 QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat, const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries, const QgsCoordinateTransformContext &transformContext );
104
118 QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries, const QgsCoordinateTransformContext &transformContext );
119
120
132 Q_DECL_DEPRECATED QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat, const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries ) SIP_DEPRECATED;
133
146 Q_DECL_DEPRECATED QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat, const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries ) SIP_DEPRECATED;
147
156 Result processCalculation( QgsFeedback *feedback = nullptr );
157
162 QString lastError() const;
163
164 private:
165 //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
166 QgsRasterCalculator() = delete;
167
172 GDALDriverH openOutputDriver();
173
178 gdal::dataset_unique_ptr openOutputFile( GDALDriverH outputDriver );
179
184 void outputGeoTransform( double *transform ) const;
185
187 Result processCalculationGPU( std::unique_ptr<QgsRasterCalcNode> calcNode, QgsFeedback *feedback = nullptr );
188
189 QString mFormulaString;
190 QString mOutputFile;
191 QString mOutputFormat;
192
194 QgsRectangle mOutputRectangle;
196
198 int mNumOutputColumns = 0;
200 int mNumOutputRows = 0;
201
202 QString mLastError;
203
204 /***/
205 QVector<QgsRasterCalculatorEntry> mRasterEntries;
206
207 QgsCoordinateTransformContext mTransformContext;
208};
209
210#endif // QGSRASTERCALCULATOR_H
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Represents an individual raster layer/band number entry within a raster calculation.
QString ref
Name of entry.
Performs raster layer calculations.
Result
Result of the calculation.
Represents a raster layer.
A rectangle specified with double values.
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
const QgsCoordinateReferenceSystem & outputCrs