QGIS API Documentation 3.39.0-Master (3aed037ce22)
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 ): color( c ), minElevation( min ), maxElevation( max ) { }
44 QColor color;
47 };
48
49 QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
51
52 QgsRelief( const QgsRelief &rh ) = delete;
53 QgsRelief &operator=( const QgsRelief &rh ) = delete;
54
60 int processRaster( QgsFeedback *feedback = nullptr );
61
62 double zFactor() const { return mZFactor; }
63 void setZFactor( double factor ) { mZFactor = factor; }
64
65 void clearReliefColors();
66 void addReliefColorClass( const QgsRelief::ReliefColor &color );
67 QList< QgsRelief::ReliefColor > reliefColors() const { return mReliefColors; }
68 void setReliefColors( const QList< QgsRelief::ReliefColor > &c ) { mReliefColors = c; }
69
74 QList< QgsRelief::ReliefColor > calculateOptimizedReliefClasses();
75
77 bool exportFrequencyDistributionToCsv( const QString &file );
78
79 private:
80#ifdef SIP_RUN
81 QgsRelief( const QgsRelief &rh );
82#endif
83
84 QString mInputFile;
85 QString mOutputFile;
86 QString mOutputFormat;
87
88 double mCellSizeX = 0.0;
89 double mCellSizeY = 0.0;
91 float mInputNodataValue = -1;
93 float mOutputNodataValue = -1;
94
95 double mZFactor = 1;
96
97 std::unique_ptr< QgsSlopeFilter > mSlopeFilter;
98 std::unique_ptr< QgsAspectFilter > mAspectFilter;
99 std::unique_ptr< QgsHillshadeFilter > mHillshadeFilter285;
100 std::unique_ptr< QgsHillshadeFilter > mHillshadeFilter300;
101 std::unique_ptr< QgsHillshadeFilter > mHillshadeFilter315;
102
103 //relief colors and corresponding elevations
104 QList< ReliefColor > mReliefColors;
105
106 bool processNineCellWindow( float *x1, float *x2, float *x3, float *x4, float *x5, float *x6, float *x7, float *x8, float *x9,
107 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
125 bool setElevationColor( double elevation, int *red, int *green, int *blue );
126
128 void setDefaultReliefColors();
129
134 int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
136 void optimiseClassBreaks( QList<int> &breaks, double *frequencies );
137
144 bool calculateRegression( const QList< QPair < int, double > > &input, double &a, double &b );
145
146};
147
148#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:63
QList< QgsRelief::ReliefColor > reliefColors() const
Definition qgsrelief.h:67
double zFactor() const
Definition qgsrelief.h:62
void setReliefColors(const QList< QgsRelief::ReliefColor > &c)
Definition qgsrelief.h:68
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