QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
42 public:
43
54 static QVector<QgsRasterCalculatorEntry> rasterEntries();
55
59 QString ref;
60
64 QgsRasterLayer *raster = nullptr;
65
69 int bandNumber = 1;
70};
71
76class ANALYSIS_EXPORT QgsRasterCalculator
77{
78 public:
79
81 enum Result
82 {
83 Success = 0,
84 CreateOutputError = 1,
85 InputLayerError = 2,
86 Canceled = 3,
87 ParserError = 4,
88 MemoryError = 5,
89 BandError = 6,
90 CalculationError = 7,
91 };
92
93
106 QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
107 const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows,
108 const QVector<QgsRasterCalculatorEntry> &rasterEntries,
109 const QgsCoordinateTransformContext &transformContext );
110
124 QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
125 const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs,
126 int nOutputColumns, int nOutputRows,
127 const QVector<QgsRasterCalculatorEntry> &rasterEntries,
128 const QgsCoordinateTransformContext &transformContext );
129
130
142 Q_DECL_DEPRECATED QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
143 const QgsRectangle &outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries ) SIP_DEPRECATED;
144
157 Q_DECL_DEPRECATED QgsRasterCalculator( const QString &formulaString, const QString &outputFile, const QString &outputFormat,
158 const QgsRectangle &outputExtent, const QgsCoordinateReferenceSystem &outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry> &rasterEntries ) SIP_DEPRECATED;
159
168 Result processCalculation( QgsFeedback *feedback = nullptr );
169
174 QString lastError() const;
175
176 private:
177 //default constructor forbidden. We need formula, output file, output format and output raster resolution obligatory
178 QgsRasterCalculator() = delete;
179
184 GDALDriverH openOutputDriver();
185
190 gdal::dataset_unique_ptr openOutputFile( GDALDriverH outputDriver );
191
196 void outputGeoTransform( double *transform ) const;
197
199 Result processCalculationGPU( std::unique_ptr< QgsRasterCalcNode > calcNode, QgsFeedback *feedback = nullptr );
200
201 QString mFormulaString;
202 QString mOutputFile;
203 QString mOutputFormat;
204
206 QgsRectangle mOutputRectangle;
208
210 int mNumOutputColumns = 0;
212 int mNumOutputRows = 0;
213
214 QString mLastError;
215
216 /***/
217 QVector<QgsRasterCalculatorEntry> mRasterEntries;
218
219 QgsCoordinateTransformContext mTransformContext;
220};
221
222#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