QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
26#include <QColor>
27#include <QMap>
28#include <QPair>
29#include <QString>
30
31class QgsAspectFilter;
32class QgsSlopeFilter;
34class QgsFeedback;
35
40class ANALYSIS_EXPORT QgsRelief
41{
42 public:
44 {
45 ReliefColor( const QColor &c, double min, double max )
46 : color( c )
47 , minElevation( min )
48 , maxElevation( max )
49 {}
50
51 QColor color;
54 };
55
56 QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
58
59 QgsRelief( const QgsRelief &rh ) = delete;
60 QgsRelief &operator=( const QgsRelief &rh ) = delete;
61
67 int processRaster( QgsFeedback *feedback = nullptr );
68
69 double zFactor() const { return mZFactor; }
70 void setZFactor( double factor ) { mZFactor = factor; }
71
72 void clearReliefColors();
73 void addReliefColorClass( const QgsRelief::ReliefColor &color );
74 QList<QgsRelief::ReliefColor> reliefColors() const { return mReliefColors; }
75 void setReliefColors( const QList<QgsRelief::ReliefColor> &c ) { mReliefColors = c; }
76
81 QList<QgsRelief::ReliefColor> calculateOptimizedReliefClasses();
82
84 bool exportFrequencyDistributionToCsv( const QString &file );
85
86 private:
87#ifdef SIP_RUN
88 QgsRelief( const QgsRelief &rh );
89#endif
90
91 QString mInputFile;
92 QString mOutputFile;
93 QString mOutputFormat;
94
95 double mCellSizeX = 0.0;
96 double mCellSizeY = 0.0;
98 float mInputNodataValue = -1;
100 float mOutputNodataValue = -1;
101
102 double mZFactor = 1;
103
104 std::unique_ptr<QgsSlopeFilter> mSlopeFilter;
105 std::unique_ptr<QgsAspectFilter> mAspectFilter;
106 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter285;
107 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter300;
108 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter315;
109
110 //relief colors and corresponding elevations
111 QList<ReliefColor> mReliefColors;
112
113 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 );
114
116 gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
117
122 GDALDriverH openOutputDriver();
123
128 gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
129
133 bool getElevationColor( double elevation, int *red, int *green, int *blue ) const;
134
136 void setDefaultReliefColors();
137
142 int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
144 void optimiseClassBreaks( QList<int> &breaks, double *frequencies );
145
152 bool calculateRegression( const QList<QPair<int, double>> &input, double &a, double &b );
153};
154
155#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.
Produces colored relief rasters from DEM.
Definition qgsrelief.h:41
void setZFactor(double factor)
Definition qgsrelief.h:70
QList< QgsRelief::ReliefColor > reliefColors() const
Definition qgsrelief.h:74
QgsRelief(const QString &inputFile, const QString &outputFile, const QString &outputFormat)
Definition qgsrelief.cpp:40
double zFactor() const
Definition qgsrelief.h:69
void setReliefColors(const QList< QgsRelief::ReliefColor > &c)
Definition qgsrelief.h:75
QgsRelief & operator=(const QgsRelief &rh)=delete
QgsRelief(const QgsRelief &rh)=delete
int processRaster(QgsFeedback *feedback=nullptr)
Starts the calculation, reads from mInputFile and stores the result in mOutputFile.
Definition qgsrelief.cpp:77
Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- direct...
std::unique_ptr< std::remove_pointer< GDALDatasetH >::type, GDALDatasetCloser > dataset_unique_ptr
Scoped GDAL dataset.
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
void * GDALDatasetH
ReliefColor(const QColor &c, double min, double max)
Definition qgsrelief.h:45