QGIS API Documentation 4.3.0-Master (7d9941090cd)
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
134 void setCreationOptions( const QStringList &list ) { mCreationOptions = list; }
135
142 QStringList creationOptions() const { return mCreationOptions; }
143
150 void setOutputNodataValue( double value ) { mOutputNodataValue = value; }
151
158 double outputNodataValue() const { return mOutputNodataValue; }
159
165 QList<QgsRasterReliefColor> calculateOptimizedReliefClasses();
166
168 bool exportFrequencyDistributionToCsv( const QString &file );
169
170 private:
171#ifdef SIP_RUN
172 QgsRelief( const QgsRelief &rh );
173#endif
174
175 QString mInputFile;
176 QString mOutputFile;
177 QString mOutputFormat;
178
179 double mCellSizeX = 0.0;
180 double mCellSizeY = 0.0;
182 float mInputNodataValue = -9999.0;
184 float mOutputNodataValue = -9999.0;
185
186 double mZFactor = 1;
187
188 QStringList mCreationOptions;
189
190 std::unique_ptr<QgsSlopeFilter> mSlopeFilter;
191 std::unique_ptr<QgsAspectFilter> mAspectFilter;
192 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter285;
193 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter300;
194 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter315;
195
196 //relief colors and corresponding elevations
197 QList<QgsRasterReliefColor> mReliefColors;
198
199 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 );
200
204 bool getElevationColor( double elevation, int *red, int *green, int *blue ) const;
205
207 void setDefaultReliefColors();
208
213 static int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
214};
215
216#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
double outputNodataValue() const
Returns no data value used for output file.
Definition qgsrelief.h:158
Result
Calculation results.
Definition qgsrelief.h:59
QgsRelief(const QString &inputFile, const QString &outputFile, const QString &outputFormat)
Constructor for QgsRelief.
Definition qgsrelief.cpp:41
void setCreationOptions(const QStringList &list)
Sets a list of data source creation options to use when creating the output raster file.
Definition qgsrelief.h:134
double zFactor() const
Returns the z factor, which controls vertical elevation exaggeration.
Definition qgsrelief.h:83
void setOutputNodataValue(double value)
Sets no data value for output file.
Definition qgsrelief.h:150
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
QStringList creationOptions() const
Returns the list of data source creation options which will be used when creating the output raster f...
Definition qgsrelief.h:142
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