QGIS API Documentation  2.99.0-Master (7d4f81d)
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 <QColor>
22 #include <QMap>
23 #include <QPair>
24 #include <QString>
25 #include "gdal.h"
26 #include "qgis_analysis.h"
27 
28 class QgsAspectFilter;
29 class QgsSlopeFilter;
30 class QgsHillshadeFilter;
31 class QProgressDialog;
32 
35 class ANALYSIS_EXPORT QgsRelief
36 {
37  public:
38  struct ReliefColor
39  {
40  ReliefColor( const QColor &c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
41  QColor color;
42  double minElevation;
43  double maxElevation;
44  };
45 
46  QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
47  ~QgsRelief();
48 
50  QgsRelief( const QgsRelief &rh ) = delete;
52  QgsRelief &operator=( const QgsRelief &rh ) = delete;
53 
57  int processRaster( QProgressDialog *p );
58 
59  double zFactor() const { return mZFactor; }
60  void setZFactor( double factor ) { mZFactor = factor; }
61 
62  void clearReliefColors();
63  void addReliefColorClass( const QgsRelief::ReliefColor &color );
64  QList< QgsRelief::ReliefColor > reliefColors() const { return mReliefColors; }
65  void setReliefColors( const QList< QgsRelief::ReliefColor > &c ) { mReliefColors = c; }
66 
69  QList< QgsRelief::ReliefColor > calculateOptimizedReliefClasses();
70 
72  bool exportFrequencyDistributionToCsv( const QString &file );
73 
74  private:
75 #ifdef SIP_RUN
76  QgsRelief( const QgsRelief &rh );
77 #endif
78 
79  QString mInputFile;
80  QString mOutputFile;
81  QString mOutputFormat;
82 
83  double mCellSizeX;
84  double mCellSizeY;
86  float mInputNodataValue;
88  float mOutputNodataValue;
89 
90  double mZFactor;
91 
92  QgsSlopeFilter *mSlopeFilter = nullptr;
93  QgsAspectFilter *mAspectFilter = nullptr;
94  QgsHillshadeFilter *mHillshadeFilter285 = nullptr;
95  QgsHillshadeFilter *mHillshadeFilter300 = nullptr;
96  QgsHillshadeFilter *mHillshadeFilter315 = nullptr;
97 
98  //relief colors and corresponding elevations
99  QList< ReliefColor > mReliefColors;
100 
101  bool processNineCellWindow( float *x1, float *x2, float *x3, float *x4, float *x5, float *x6, float *x7, float *x8, float *x9,
102  unsigned char *red, unsigned char *green, unsigned char *blue );
103 
105  GDALDatasetH openInputFile( int &nCellsX, int &nCellsY );
106 
109  GDALDriverH openOutputDriver();
110 
113  GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
114 
116  bool setElevationColor( double elevation, int *red, int *green, int *blue );
117 
119  void setDefaultReliefColors();
120 
123  int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
125  void optimiseClassBreaks( QList<int> &breaks, double *frequencies );
126 
132  bool calculateRegression( const QList< QPair < int, double > > &input, double &a, double &b );
133 
134 };
135 
136 #endif // QGSRELIEF_H
double zFactor() const
Definition: qgsrelief.h:59
void setZFactor(double factor)
Definition: qgsrelief.h:60
QList< QgsRelief::ReliefColor > reliefColors() const
Definition: qgsrelief.h:64
Calculates aspect values in a window of 3x3 cells based on first order derivatives in x- and y- direc...
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:452
void * GDALDatasetH
ReliefColor(const QColor &c, double min, double max)
Definition: qgsrelief.h:40
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:437
Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- direct...
void setReliefColors(const QList< QgsRelief::ReliefColor > &c)
Definition: qgsrelief.h:65
Produces colored relief rasters from DEM.
Definition: qgsrelief.h:35