QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 <QColor>
22#include <QMap>
23#include <QPair>
24#include <QString>
25#include "gdal.h"
26#include "qgsogrutils.h"
27#include "qgis_analysis.h"
28
29class QgsAspectFilter;
30class QgsSlopeFilter;
32class QgsFeedback;
33
38class ANALYSIS_EXPORT QgsRelief
39{
40 public:
42 {
43 ReliefColor( const QColor &c, double min, double max )
44 : color( c ), minElevation( min ), maxElevation( max ) {}
45 QColor color;
48 };
49
50 QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
52
53 QgsRelief( const QgsRelief &rh ) = delete;
54 QgsRelief &operator=( const QgsRelief &rh ) = delete;
55
61 int processRaster( QgsFeedback *feedback = nullptr );
62
63 double zFactor() const { return mZFactor; }
64 void setZFactor( double factor ) { mZFactor = factor; }
65
66 void clearReliefColors();
67 void addReliefColorClass( const QgsRelief::ReliefColor &color );
68 QList<QgsRelief::ReliefColor> reliefColors() const { return mReliefColors; }
69 void setReliefColors( const QList<QgsRelief::ReliefColor> &c ) { mReliefColors = c; }
70
75 QList<QgsRelief::ReliefColor> calculateOptimizedReliefClasses();
76
78 bool exportFrequencyDistributionToCsv( const QString &file );
79
80 private:
81#ifdef SIP_RUN
82 QgsRelief( const QgsRelief &rh );
83#endif
84
85 QString mInputFile;
86 QString mOutputFile;
87 QString mOutputFormat;
88
89 double mCellSizeX = 0.0;
90 double mCellSizeY = 0.0;
92 float mInputNodataValue = -1;
94 float mOutputNodataValue = -1;
95
96 double mZFactor = 1;
97
98 std::unique_ptr<QgsSlopeFilter> mSlopeFilter;
99 std::unique_ptr<QgsAspectFilter> mAspectFilter;
100 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter285;
101 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter300;
102 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter315;
103
104 //relief colors and corresponding elevations
105 QList<ReliefColor> mReliefColors;
106
107 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 );
108
110 gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
111
116 GDALDriverH openOutputDriver();
117
122 gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
123
127 bool getElevationColor( double elevation, int *red, int *green, int *blue ) const;
128
130 void setDefaultReliefColors();
131
136 int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
138 void optimiseClassBreaks( QList<int> &breaks, double *frequencies );
139
146 bool calculateRegression( const QList<QPair<int, double>> &input, double &a, double &b );
147};
148
149#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:39
void setZFactor(double factor)
Definition qgsrelief.h:64
QList< QgsRelief::ReliefColor > reliefColors() const
Definition qgsrelief.h:68
double zFactor() const
Definition qgsrelief.h:63
void setReliefColors(const QList< QgsRelief::ReliefColor > &c)
Definition qgsrelief.h:69
QgsRelief & operator=(const QgsRelief &rh)=delete
QgsRelief(const QgsRelief &rh)=delete
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:43