QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 public:
34 QString group() const final;
35 QString groupId() const final;
36 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) final;
37
38
39 protected:
40 virtual void addSpecificAlgorithmParams() = 0;
41 virtual bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) = 0;
42 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
43 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) final;
44 virtual void processRasterStack( QgsProcessingFeedback *feedback ) = 0;
45
46 std::vector<QgsRasterAnalysisUtils::RasterLogicInput> mInputs;
47 bool mIgnoreNoData = false;
49 double mNoDataValue = -9999;
50 int mLayerWidth = 0;
51 int mLayerHeight = 0;
52 QgsRectangle mExtent;
54 double mRasterUnitsPerPixelX = 0;
55 double mRasterUnitsPerPixelY = 0;
56 std::unique_ptr<QgsRasterDataProvider> mOutputRasterDataProvider;
57};
58
59class QgsCellStatisticsAlgorithm : public QgsCellStatisticsAlgorithmBase
60{
61 public:
62 QgsCellStatisticsAlgorithm() = default;
63 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatistics.svg" ) ); }
64 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatistics.svg" ) ); }
65 QString name() const override;
66 QString displayName() const override;
67 QStringList tags() const override;
68 QString shortHelpString() const override;
69 QgsCellStatisticsAlgorithm *createInstance() const override SIP_FACTORY;
70
71 protected:
72 void addSpecificAlgorithmParams() override;
73 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
74 void processRasterStack( QgsProcessingFeedback *feedback ) override;
75
76 private:
77 QgsRasterAnalysisUtils::CellValueStatisticMethods mMethod = QgsRasterAnalysisUtils::CellValueStatisticMethods::Sum;
78};
79
80
81class QgsCellStatisticsPercentileAlgorithm : public QgsCellStatisticsAlgorithmBase
82{
83 public:
84 QgsCellStatisticsPercentileAlgorithm() = default;
85 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentile.svg" ) ); }
86 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentile.svg" ) ); }
87 QString name() const override;
88 QString displayName() const override;
89 QStringList tags() const override;
90 QString shortHelpString() const override;
91 QgsCellStatisticsPercentileAlgorithm *createInstance() const override SIP_FACTORY;
92
93 protected:
94 void addSpecificAlgorithmParams() override;
95 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
96 void processRasterStack( QgsProcessingFeedback *feedback ) override;
97
98 private:
99 QgsRasterAnalysisUtils::CellValuePercentileMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentileMethods::NearestRankPercentile;
100 double mPercentile = 0.0;
101};
102
103
104class QgsCellStatisticsPercentRankFromValueAlgorithm : public QgsCellStatisticsAlgorithmBase
105{
106 public:
107 QgsCellStatisticsPercentRankFromValueAlgorithm() = default;
108 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
109 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
110 QString name() const override;
111 QString displayName() const override;
112 QStringList tags() const override;
113 QString shortHelpString() const override;
114 QgsCellStatisticsPercentRankFromValueAlgorithm *createInstance() const override SIP_FACTORY;
115
116 protected:
117 void addSpecificAlgorithmParams() override;
118 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
119 void processRasterStack( QgsProcessingFeedback *feedback ) override;
120
121 private:
122 QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentRankMethods::InterpolatedPercentRankInc;
123 double mValue = 0.0;
124};
125
126
127class QgsCellStatisticsPercentRankFromRasterAlgorithm : public QgsCellStatisticsAlgorithmBase
128{
129 public:
130 QgsCellStatisticsPercentRankFromRasterAlgorithm() = default;
131 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
132 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmCellStatisticsPercentRank.svg" ) ); }
133 QString name() const override;
134 QString displayName() const override;
135 QStringList tags() const override;
136 QString shortHelpString() const override;
137 QgsCellStatisticsPercentRankFromRasterAlgorithm *createInstance() const override SIP_FACTORY;
138
139 protected:
140 void addSpecificAlgorithmParams() override;
141 bool prepareSpecificAlgorithmParameters( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
142 void processRasterStack( QgsProcessingFeedback *feedback ) override;
143
144 private:
145 QgsRasterAnalysisUtils::CellValuePercentRankMethods mMethod = QgsRasterAnalysisUtils::CellValuePercentRankMethods::InterpolatedPercentRankInc;
146 std::unique_ptr<QgsRasterInterface> mValueRasterInterface;
147 int mValueRasterBand = 1;
148};
149
150
152
153#endif // QGSALGORITHMCELLSTATISTICS_H
DataType
Raster data types.
Definition qgis.h:351
@ 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