QGIS API Documentation 3.37.0-Master (49cede7946b)
Loading...
Searching...
No Matches
qgsalgorithmcellstatistics.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmcellstatistics.h
3 ---------------------
4 begin : May 2020
5 copyright : (C) 2020 by Clemens Raffler
6 email : clemens dot raffler at gmail dot com
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 QGSALGORITHMCELLSTATISTICS_H
19#define QGSALGORITHMCELLSTATISTICS_H
20
21#define SIP_NO_FILE
22
23#include "qgis_sip.h"
24#include "qgsapplication.h"
26#include "qgsrasterprojector.h"
28
30
31class QgsCellStatisticsAlgorithmBase : public QgsProcessingAlgorithm
32{
33
34 public:
35 QString group() const final;
36 QString groupId() const final;
37 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) final;
38
39
40 protected:
41 virtual void addSpecificAlgorithmParams() = 0;
42 virtual bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0;
43 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
44 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
45 virtual void processRasterStack( QgsProcessingFeedback *feedback ) = 0;
46
47 std::vector< QgsRasterAnalysisUtils::RasterLogicInput > mInputs;
48 bool mIgnoreNoData = false;
50 double mNoDataValue = -9999;
51 int mLayerWidth = 0;
52 int mLayerHeight = 0;
53 QgsRectangle mExtent;
55 double mRasterUnitsPerPixelX = 0;
56 double mRasterUnitsPerPixelY = 0;
57 std::unique_ptr< QgsRasterDataProvider > mOutputRasterDataProvider;
58};
59
60class QgsCellStatisticsAlgorithm : public QgsCellStatisticsAlgorithmBase
61{
62 public:
63 QgsCellStatisticsAlgorithm() = default;
64 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatistics.svg" ) ); }
65 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatistics.svg" ) ); }
66 QString name() const override;
67 QString displayName() const override;
68 QStringList tags() const override;
69 QString shortHelpString() const override;
70 QgsCellStatisticsAlgorithm *createInstance() const override SIP_FACTORY;
71
72 protected:
73 void addSpecificAlgorithmParams() override;
74 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
75 void processRasterStack( QgsProcessingFeedback *feedback ) override;
76
77 private:
78 QgsRasterAnalysisUtils::CellValueStatisticMethods mMethod = QgsRasterAnalysisUtils::CellValueStatisticMethods::Sum;
79
80};
81
82
83class QgsCellStatisticsPercentileAlgorithm : public QgsCellStatisticsAlgorithmBase
84{
85 public:
86 QgsCellStatisticsPercentileAlgorithm() = default;
87 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentile.svg" ) ); }
88 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentile.svg" ) ); }
89 QString name() const override;
90 QString displayName() const override;
91 QStringList tags() const override;
92 QString shortHelpString() const override;
93 QgsCellStatisticsPercentileAlgorithm *createInstance() const override SIP_FACTORY;
94
95 protected:
96 void addSpecificAlgorithmParams() override;
97 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
98 void processRasterStack( QgsProcessingFeedback *feedback ) override;
99
100 private:
101 QgsRasterAnalysisUtils::CellValuePercentileMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentileMethods::NearestRankPercentile;
102 double mPercentile = 0.0;
103};
104
105
106class QgsCellStatisticsPercentRankFromValueAlgorithm : public QgsCellStatisticsAlgorithmBase
107{
108 public:
109 QgsCellStatisticsPercentRankFromValueAlgorithm() = default;
110 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
111 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
112 QString name() const override;
113 QString displayName() const override;
114 QStringList tags() const override;
115 QString shortHelpString() const override;
116 QgsCellStatisticsPercentRankFromValueAlgorithm *createInstance() const override SIP_FACTORY;
117
118 protected:
119 void addSpecificAlgorithmParams() override;
120 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
121 void processRasterStack( QgsProcessingFeedback *feedback ) override;
122
123 private:
124 QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentRankMethods::InterpolatedPercentRankInc;
125 double mValue = 0.0;
126
127};
128
129
130class QgsCellStatisticsPercentRankFromRasterAlgorithm : public QgsCellStatisticsAlgorithmBase
131{
132 public:
133 QgsCellStatisticsPercentRankFromRasterAlgorithm() = default;
134 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
135 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
136 QString name() const override;
137 QString displayName() const override;
138 QStringList tags() const override;
139 QString shortHelpString() const override;
140 QgsCellStatisticsPercentRankFromRasterAlgorithm *createInstance() const override SIP_FACTORY;
141
142 protected:
143 void addSpecificAlgorithmParams() override;
144 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
145 void processRasterStack( QgsProcessingFeedback *feedback ) override;
146
147 private:
148 QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentRankMethods::InterpolatedPercentRankInc;
149 std::unique_ptr< QgsRasterInterface > mValueRasterInterface;
150 int mValueRasterBand = 1;
151
152};
153
154
156
157#endif // QGSALGORITHMCELLSTATISTICS_H
158
DataType
Raster data types.
Definition qgis.h:288
@ UnknownDataType
Unknown or unspecified type.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
This class represents a coordinate reference system (CRS).
Abstract base class for processing algorithms.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Prepares the algorithm to run using the specified parameters.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
virtual QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)=0
Runs the algorithm using the specified parameters.
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
Base class for processing filters like renderers, reprojector, resampler etc.
A rectangle specified with double values.
#define SIP_FACTORY
Definition qgis_sip.h:76