QGIS API Documentation 4.3.0-Master (7c7bd4d7018)
Loading...
Searching...
No Matches
qgsrelief.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrelief.h - description
3 ---------------------------
4 begin : November 2011
5 copyright : (C) 2011 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 QGSRELIEF_H
19#define QGSRELIEF_H
20
21#include <gdal.h>
22
23#include "qgis_analysis.h"
24#include "qgsogrutils.h"
25#include "qgsrasterlayerutils.h"
26
27#include <QColor>
28#include <QMap>
29#include <QPair>
30#include <QString>
31
32class QgsAspectFilter;
33class QgsSlopeFilter;
35class QgsFeedback;
36
41class ANALYSIS_EXPORT QgsRelief
42{
43 public:
47 QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
49
50 QgsRelief( const QgsRelief &rh ) = delete;
51 QgsRelief &operator=( const QgsRelief &rh ) = delete;
52
58 enum class Result : int
59 {
60 Success = 0,
61 InvalidInput = 1,
62 OutputCreationFailed = 3,
63 InvalidInputSize = 6,
64 Canceled = 7,
65 };
66
76 QgsRelief::Result processRaster( QgsFeedback *feedback = nullptr );
77
83 double zFactor() const { return mZFactor; }
84
90 void setZFactor( double factor ) { mZFactor = factor; }
91
99 void clearReliefColors();
100
108 void addReliefColorClass( const QgsRasterReliefColor &color );
109
117 QList<QgsRasterReliefColor> reliefColors() const { return mReliefColors; }
118
126 void setReliefColors( const QList<QgsRasterReliefColor> &c ) { mReliefColors = c; }
127
133 QList<QgsRasterReliefColor> calculateOptimizedReliefClasses();
134
136 bool exportFrequencyDistributionToCsv( const QString &file );
137
138 private:
139#ifdef SIP_RUN
140 QgsRelief( const QgsRelief &rh );
141#endif
142
143 QString mInputFile;
144 QString mOutputFile;
145 QString mOutputFormat;
146
147 double mCellSizeX = 0.0;
148 double mCellSizeY = 0.0;
150 float mInputNodataValue = -1;
152 float mOutputNodataValue = -1;
153
154 double mZFactor = 1;
155
156 std::unique_ptr<QgsSlopeFilter> mSlopeFilter;
157 std::unique_ptr<QgsAspectFilter> mAspectFilter;
158 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter285;
159 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter300;
160 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter315;
161
162 //relief colors and corresponding elevations
163 QList<QgsRasterReliefColor> mReliefColors;
164
165 bool processNineCellWindow( float *x1, float *x2, float *x3, float *x4, float *x5, float *x6, float *x7, float *x8, float *x9, unsigned char *red, unsigned char *green, unsigned char *blue );
166
170 bool getElevationColor( double elevation, int *red, int *green, int *blue ) const;
171
173 void setDefaultReliefColors();
174
179 static int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
180};
181
182#endif // QGSRELIEF_H
Calculates aspect values in a window of 3x3 cells based on first order derivatives in x- and y- direc...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A hillshade filter.
Defines elevation range and color for raster relief coloring.
Produces colored relief rasters from DEM.
Definition qgsrelief.h:42
void setZFactor(double factor)
Sets the z factor, which controls vertical elevation exaggeration.
Definition qgsrelief.h:90
Result
Calculation results.
Definition qgsrelief.h:59
QgsRelief(const QString &inputFile, const QString &outputFile, const QString &outputFormat)
Constructor for QgsRelief.
Definition qgsrelief.cpp:41
double zFactor() const
Returns the z factor, which controls vertical elevation exaggeration.
Definition qgsrelief.h:83
QList< QgsRasterReliefColor > reliefColors() const
Returns a list of all relief colors.
Definition qgsrelief.h:117
QgsRelief & operator=(const QgsRelief &rh)=delete
QgsRelief(const QgsRelief &rh)=delete
void setReliefColors(const QList< QgsRasterReliefColor > &c)
Sets the list of relief colors.
Definition qgsrelief.h:126
Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- direct...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c