25using namespace Qt::StringLiterals;
29QString QgsSlopeAlgorithm::name()
const
34QString QgsSlopeAlgorithm::displayName()
const
36 return QObject::tr(
"Slope" );
39QStringList QgsSlopeAlgorithm::tags()
const
41 return QObject::tr(
"dem,slope,terrain" ).split(
',' );
44QString QgsSlopeAlgorithm::group()
const
46 return QObject::tr(
"Raster terrain analysis" );
49QString QgsSlopeAlgorithm::groupId()
const
51 return u
"rasterterrainanalysis"_s;
54QString QgsSlopeAlgorithm::shortHelpString()
const
57 "This algorithm calculates the angle of inclination "
58 "of the terrain from an input raster layer. The slope "
59 "is expressed in degrees."
63QString QgsSlopeAlgorithm::shortDescription()
const
65 return QObject::tr(
"Calculates the angle of inclination of the terrain from an input raster layer." );
68QgsSlopeAlgorithm *QgsSlopeAlgorithm::createInstance()
const
70 return new QgsSlopeAlgorithm();
73void QgsSlopeAlgorithm::initAlgorithm(
const QVariantMap & )
78 zFactorParam->setHelp( QObject::tr(
"Multiplication factor to convert vertical Z units to horizontal XY units." ) );
79 zFactorParam->setMetadata( { QVariantMap( { { u
"widget_wrapper"_s, QVariantMap( { { u
"decimals"_s, 12 } } ) } } ) } );
80 addParameter( zFactorParam.release() );
84 addParameter( outputNodataParam.release() );
86 auto creationOptsParam = std::make_unique<QgsProcessingParameterString>( u
"CREATION_OPTIONS"_s, QObject::tr(
"Creation options" ), QVariant(),
false,
true );
87 creationOptsParam->setMetadata( QVariantMap( { { u
"widget_wrapper"_s, QVariantMap( { { u
"widget_type"_s, u
"rasteroptions"_s } } ) } } ) );
89 addParameter( creationOptsParam.release() );
96 QgsRasterLayer *layer = parameterAsRasterLayer( parameters, u
"INPUT"_s, context );
102 mLayerSource = layer->
source();
108 const double zFactor = parameterAsDouble( parameters, u
"Z_FACTOR"_s, context );
109 const QString creationOptions = parameterAsString( parameters, u
"CREATION_OPTIONS"_s, context ).trimmed();
110 const double outputNodata = parameterAsDouble( parameters, u
"NODATA"_s, context );
112 const QString outputFile = parameterAsOutputLayer( parameters, u
"OUTPUT"_s, context );
113 const QString outputFormat = parameterAsOutputRasterFormat( parameters, u
"OUTPUT"_s, context );
116 if ( !creationOptions.isEmpty() )
118 slope.setCreationOptions( creationOptions.split(
'|' ) );
120 slope.setOutputNodataValue( outputNodata );
121 slope.setZFactor( zFactor );
122 slope.processRaster( feedback );
125 outputs.insert( u
"OUTPUT"_s, outputFile );
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
@ Double
Double/float values.
QString source() const
Returns the source for the layer.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
A raster layer parameter for processing algorithms.
Represents a raster layer.
Calculates slope values in a window of 3x3 cells based on first order derivatives in x- and y- direct...