QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
33 class ANALYSIS_EXPORT QgsRelief
34 {
35  public:
36  struct ReliefColor
37  {
38  ReliefColor( const QColor& c, double min, double max ): color( c ), minElevation( min ), maxElevation( max ) { }
39  QColor color;
40  double minElevation;
41  double maxElevation;
42  };
43 
44  QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
45  ~QgsRelief();
46 
50  int processRaster( QProgressDialog* p );
51 
52  double zFactor() const { return mZFactor; }
53  void setZFactor( double factor ) { mZFactor = factor; }
54 
55  void clearReliefColors();
56  void addReliefColorClass( const ReliefColor& color );
57  const QList< ReliefColor >& reliefColors() const { return mReliefColors; }
58  void setReliefColors( const QList< ReliefColor >& c ) { mReliefColors = c; }
59 
62  QList< ReliefColor > calculateOptimizedReliefClasses();
63 
65  bool exportFrequencyDistributionToCsv( const QString& file );
66 
67  private:
68 
69  QString mInputFile;
70  QString mOutputFile;
71  QString mOutputFormat;
72 
73  double mCellSizeX;
74  double mCellSizeY;
79 
80  double mZFactor;
81 
87 
88  //relief colors and corresponding elevations
89  QList< ReliefColor > mReliefColors;
90 
91  bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
92  unsigned char* red, unsigned char* green, unsigned char* blue );
93 
95  GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );
98  GDALDriverH openOutputDriver();
101  GDALDatasetH openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
102 
104  bool setElevationColor( double elevation, int* red, int* green, int* blue );
105 
107  void setDefaultReliefColors();
110  int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
112  void optimiseClassBreaks( QList<int>& breaks, double* frequencies );
118  bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );
119 };
120 
121 #endif // QGSRELIEF_H
QgsHillshadeFilter * mHillshadeFilter300
Definition: qgsrelief.h:85
double mCellSizeY
Definition: qgsrelief.h:74
void setZFactor(double factor)
Definition: qgsrelief.h:53
double mZFactor
Definition: qgsrelief.h:80
double mCellSizeX
Definition: qgsrelief.h:73
QString mOutputFile
Definition: qgsrelief.h:70
QgsSlopeFilter * mSlopeFilter
Definition: qgsrelief.h:82
float mOutputNodataValue
The nodata value of the output layer.
Definition: qgsrelief.h:78
double zFactor() const
Definition: qgsrelief.h:52
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...
float mInputNodataValue
The nodata value of the input layer.
Definition: qgsrelief.h:76
QString mInputFile
Definition: qgsrelief.h:69
ReliefColor(const QColor &c, double min, double max)
Definition: qgsrelief.h:38
QgsAspectFilter * mAspectFilter
Definition: qgsrelief.h:83
QList< ReliefColor > mReliefColors
Definition: qgsrelief.h:89
QgsHillshadeFilter * mHillshadeFilter285
Definition: qgsrelief.h:84
QString file
Definition: qgssvgcache.cpp:76
QString mOutputFormat
Definition: qgsrelief.h:71
Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- direct...
QgsHillshadeFilter * mHillshadeFilter315
Definition: qgsrelief.h:86
const QList< ReliefColor > & reliefColors() const
Definition: qgsrelief.h:57
void setReliefColors(const QList< ReliefColor > &c)
Definition: qgsrelief.h:58
double ANALYSIS_EXPORT min(double x, double y)
returns the minimum of two doubles or the first argument if both are equal
Produces coloured relief rasters from DEM.
Definition: qgsrelief.h:33