QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
27 class QgsAspectFilter;
28 class QgsSlopeFilter;
29 class QgsHillshadeFilter;
30 class QProgressDialog;
31 
34 class ANALYSIS_EXPORT QgsRelief
35 {
36  public:
37  struct ReliefColor
38  {
39  ReliefColor( const QColor& c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
41  double minElevation;
42  double maxElevation;
43  };
44 
45  QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
46  ~QgsRelief();
47 
51  int processRaster( QProgressDialog* p );
52 
53  double zFactor() const { return mZFactor; }
54  void setZFactor( double factor ) { mZFactor = factor; }
55 
56  void clearReliefColors();
57  void addReliefColorClass( const ReliefColor& color );
58  const QList< ReliefColor >& reliefColors() const { return mReliefColors; }
59  void setReliefColors( const QList< ReliefColor >& c ) { mReliefColors = c; }
60 
63  QList< ReliefColor > calculateOptimizedReliefClasses();
64 
66  bool exportFrequencyDistributionToCsv( const QString& file );
67 
68  private:
69 
70  QString mInputFile;
71  QString mOutputFile;
72  QString mOutputFormat;
73 
74  double mCellSizeX;
75  double mCellSizeY;
77  float mInputNodataValue;
79  float mOutputNodataValue;
80 
81  double mZFactor;
82 
83  QgsSlopeFilter* mSlopeFilter;
84  QgsAspectFilter* mAspectFilter;
85  QgsHillshadeFilter* mHillshadeFilter285;
86  QgsHillshadeFilter* mHillshadeFilter300;
87  QgsHillshadeFilter* mHillshadeFilter315;
88 
89  //relief colors and corresponding elevations
90  QList< ReliefColor > mReliefColors;
91 
92  bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
93  unsigned char* red, unsigned char* green, unsigned char* blue );
94 
96  GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
99  GDALDriverH openOutputDriver();
102  GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
103 
105  bool setElevationColor( double elevation, int* red, int* green, int* blue );
106 
108  void setDefaultReliefColors();
111  int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
113  void optimiseClassBreaks( QList<int>& breaks, double* frequencies );
119  bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );
120 
121  QgsRelief( const QgsRelief& rh );
122  QgsRelief& operator=( const QgsRelief& rh );
123 };
124 
125 #endif // QGSRELIEF_H
double zFactor() const
Definition: qgsrelief.h:53
void setZFactor(double factor)
Definition: qgsrelief.h:54
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
Calculates aspect values in a window of 3x3 cells based on first order derivatives in x- and y- direc...
void * GDALDatasetH
ReliefColor(const QColor &c, double min, double max)
Definition: qgsrelief.h:39
Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- direct...
const QList< ReliefColor > & reliefColors() const
Definition: qgsrelief.h:58
void setReliefColors(const QList< ReliefColor > &c)
Definition: qgsrelief.h:59
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
Produces colored relief rasters from DEM.
Definition: qgsrelief.h:34