QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 ), minElevation( min ), maxElevation( max ) {}
47
48 QColor color;
51 };
52
53 QgsRelief( const QString &inputFile, const QString &outputFile, const QString &outputFormat );
55
56 QgsRelief( const QgsRelief &rh ) = delete;
57 QgsRelief &operator=( const QgsRelief &rh ) = delete;
58
64 int processRaster( QgsFeedback *feedback = nullptr );
65
66 double zFactor() const { return mZFactor; }
67 void setZFactor( double factor ) { mZFactor = factor; }
68
69 void clearReliefColors();
70 void addReliefColorClass( const QgsRelief::ReliefColor &color );
71 QList<QgsRelief::ReliefColor> reliefColors() const { return mReliefColors; }
72 void setReliefColors( const QList<QgsRelief::ReliefColor> &c ) { mReliefColors = c; }
73
78 QList<QgsRelief::ReliefColor> calculateOptimizedReliefClasses();
79
81 bool exportFrequencyDistributionToCsv( const QString &file );
82
83 private:
84#ifdef SIP_RUN
85 QgsRelief( const QgsRelief &rh );
86#endif
87
88 QString mInputFile;
89 QString mOutputFile;
90 QString mOutputFormat;
91
92 double mCellSizeX = 0.0;
93 double mCellSizeY = 0.0;
95 float mInputNodataValue = -1;
97 float mOutputNodataValue = -1;
98
99 double mZFactor = 1;
100
101 std::unique_ptr<QgsSlopeFilter> mSlopeFilter;
102 std::unique_ptr<QgsAspectFilter> mAspectFilter;
103 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter285;
104 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter300;
105 std::unique_ptr<QgsHillshadeFilter> mHillshadeFilter315;
106
107 //relief colors and corresponding elevations
108 QList<ReliefColor> mReliefColors;
109
110 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 );
111
113 gdal::dataset_unique_ptr openInputFile( int &nCellsX, int &nCellsY );
114
119 GDALDriverH openOutputDriver();
120
125 gdal::dataset_unique_ptr openOutputFile( GDALDatasetH inputDataset, GDALDriverH outputDriver );
126
130 bool getElevationColor( double elevation, int *red, int *green, int *blue ) const;
131
133 void setDefaultReliefColors();
134
139 int frequencyClassForElevation( double elevation, double minElevation, double elevationClassRange );
141 void optimiseClassBreaks( QList<int> &breaks, double *frequencies );
142
149 bool calculateRegression( const QList<QPair<int, double>> &input, double &a, double &b );
150};
151
152#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:67
QList< QgsRelief::ReliefColor > reliefColors() const
Definition qgsrelief.h:71
QgsRelief(const QString &inputFile, const QString &outputFile, const QString &outputFormat)
Definition qgsrelief.cpp:37
double zFactor() const
Definition qgsrelief.h:66
void setReliefColors(const QList< QgsRelief::ReliefColor > &c)
Definition qgsrelief.h:72
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:74
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