QGIS API Documentation 3.43.0-Master (7996e1b587e)
qgsalgorithmrandomraster.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmrandomraster.cpp
3 ---------------------
4 begin : May 2020
5 copyright : (C) 2020 by Clemens Raffler
6 email : clemens dot raffler at gmail dot com
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
19#include "qgsrasterfilewriter.h"
20#include "qgsstringutils.h"
21#include "random"
22#include "limits"
23
25
26//
27// QgsRandomRasterAlgorithmBase
28//
29QString QgsRandomRasterAlgorithmBase::group() const
30{
31 return QObject::tr( "Raster creation" );
32}
33
34QString QgsRandomRasterAlgorithmBase::groupId() const
35{
36 return QStringLiteral( "rastercreation" );
37}
38
39void QgsRandomRasterAlgorithmBase::initAlgorithm( const QVariantMap & )
40{
41 addParameter( new QgsProcessingParameterExtent( QStringLiteral( "EXTENT" ), QObject::tr( "Desired extent" ) ) );
42 addParameter( new QgsProcessingParameterCrs( QStringLiteral( "TARGET_CRS" ), QObject::tr( "Target CRS" ), QStringLiteral( "ProjectCrs" ) ) );
43 addParameter( new QgsProcessingParameterNumber( QStringLiteral( "PIXEL_SIZE" ), QObject::tr( "Pixel size" ), Qgis::ProcessingNumberParameterType::Double, 1, false, 0 ) );
44
45 //add specific parameters
46 addAlgorithmParams();
47
48 // backwards compatibility parameter
49 // TODO QGIS 4: remove parameter and related logic
50 auto createOptsParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "CREATE_OPTIONS" ), QObject::tr( "Creation options" ), QVariant(), false, true );
51 createOptsParam->setMetadata( QVariantMap( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "widget_type" ), QStringLiteral( "rasteroptions" ) } } ) } } ) );
52 createOptsParam->setFlags( createOptsParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
53 addParameter( createOptsParam.release() );
54
55 auto creationOptsParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "CREATION_OPTIONS" ), QObject::tr( "Creation options" ), QVariant(), false, true );
56 creationOptsParam->setMetadata( QVariantMap( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "widget_type" ), QStringLiteral( "rasteroptions" ) } } ) } } ) );
57 creationOptsParam->setFlags( creationOptsParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
58 addParameter( creationOptsParam.release() );
59
60 addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output raster" ) ) );
61}
62
63bool QgsRandomRasterAlgorithmBase::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
64{
65 Q_UNUSED( feedback );
66 mCrs = parameterAsCrs( parameters, QStringLiteral( "TARGET_CRS" ), context );
67 mExtent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context, mCrs );
68 mPixelSize = parameterAsDouble( parameters, QStringLiteral( "PIXEL_SIZE" ), context );
69
70 if ( mPixelSize <= 0 )
71 {
72 throw QgsProcessingException( QObject::tr( "Pixel size must be greater than 0." ) );
73 }
74
75 return true;
76}
77
78QVariantMap QgsRandomRasterAlgorithmBase::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
79{
80 const int typeId = parameterAsInt( parameters, QStringLiteral( "OUTPUT_TYPE" ), context );
81 //prepare specific parameters
82 mRasterDataType = getRasterDataType( typeId );
83 prepareRandomParameters( parameters, context );
84
85 std::random_device rd {};
86 std::mt19937 mersenneTwister { rd() };
87
88 QString creationOptions = parameterAsString( parameters, QStringLiteral( "CREATION_OPTIONS" ), context ).trimmed();
89 // handle backwards compatibility parameter CREATE_OPTIONS
90 const QString optionsString = parameterAsString( parameters, QStringLiteral( "CREATE_OPTIONS" ), context );
91 if ( !optionsString.isEmpty() )
92 creationOptions = optionsString;
93
94 const QString outputFile = parameterAsOutputLayer( parameters, QStringLiteral( "OUTPUT" ), context );
95 const QFileInfo fi( outputFile );
96 const QString outputFormat = QgsRasterFileWriter::driverForExtension( fi.suffix() );
97
98 // round up width and height to the nearest integer as GDAL does (e.g. in gdal_rasterize)
99 // see https://github.com/qgis/QGIS/issues/43547
100 const int rows = static_cast<int>( 0.5 + mExtent.height() / mPixelSize );
101 const int cols = static_cast<int>( 0.5 + mExtent.width() / mPixelSize );
102
103 //build new raster extent based on number of columns and cellsize
104 //this prevents output cellsize being calculated too small
105 const QgsRectangle rasterExtent = QgsRectangle( mExtent.xMinimum(), mExtent.yMaximum() - ( rows * mPixelSize ), mExtent.xMinimum() + ( cols * mPixelSize ), mExtent.yMaximum() );
106
107 auto writer = std::make_unique<QgsRasterFileWriter>( outputFile );
108 writer->setOutputProviderKey( QStringLiteral( "gdal" ) );
109 if ( !creationOptions.isEmpty() )
110 {
111 writer->setCreationOptions( creationOptions.split( '|' ) );
112 }
113
114 writer->setOutputFormat( outputFormat );
115 std::unique_ptr<QgsRasterDataProvider> provider( writer->createOneBandRaster( mRasterDataType, cols, rows, rasterExtent, mCrs ) );
116 if ( !provider )
117 throw QgsProcessingException( QObject::tr( "Could not create raster output: %1" ).arg( outputFile ) );
118 if ( !provider->isValid() )
119 throw QgsProcessingException( QObject::tr( "Could not create raster output %1: %2" ).arg( outputFile, provider->error().message( QgsErrorMessage::Text ) ) );
120
121 const double step = rows > 0 ? 100.0 / rows : 1;
122
123 for ( int row = 0; row < rows; row++ )
124 {
125 if ( feedback->isCanceled() )
126 {
127 break;
128 }
129 //prepare raw data depending on raster data type
130 QgsRasterBlock block( mRasterDataType, cols, 1 );
131 switch ( mRasterDataType )
132 {
134 {
135 std::vector<quint8> byteRow( cols );
136 for ( int col = 0; col < cols; col++ )
137 {
138 byteRow[col] = static_cast<quint8>( generateRandomLongValue( mersenneTwister ) );
139 }
140 block.setData( QByteArray( reinterpret_cast<const char *>( byteRow.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Byte ) * cols ) );
141 break;
142 }
144 {
145 std::vector<qint8> int8Row( cols );
146 for ( int col = 0; col < cols; col++ )
147 {
148 int8Row[col] = static_cast<qint8>( generateRandomLongValue( mersenneTwister ) );
149 }
150 block.setData( QByteArray( reinterpret_cast<const char *>( int8Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Int8 ) * cols ) );
151 break;
152 }
154 {
155 std::vector<qint16> int16Row( cols );
156 for ( int col = 0; col < cols; col++ )
157 {
158 int16Row[col] = static_cast<qint16>( generateRandomLongValue( mersenneTwister ) );
159 }
160 block.setData( QByteArray( reinterpret_cast<const char *>( int16Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Int16 ) * cols ) );
161 break;
162 }
164 {
165 std::vector<quint16> uInt16Row( cols );
166 for ( int col = 0; col < cols; col++ )
167 {
168 uInt16Row[col] = static_cast<quint16>( generateRandomLongValue( mersenneTwister ) );
169 }
170 block.setData( QByteArray( reinterpret_cast<const char *>( uInt16Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::UInt16 ) * cols ) );
171 break;
172 }
174 {
175 std::vector<qint32> int32Row( cols );
176 for ( int col = 0; col < cols; col++ )
177 {
178 int32Row[col] = generateRandomLongValue( mersenneTwister );
179 }
180 block.setData( QByteArray( reinterpret_cast<const char *>( int32Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Int32 ) * cols ) );
181 break;
182 }
184 {
185 std::vector<quint32> uInt32Row( cols );
186 for ( int col = 0; col < cols; col++ )
187 {
188 uInt32Row[col] = static_cast<quint32>( generateRandomLongValue( mersenneTwister ) );
189 }
190 block.setData( QByteArray( reinterpret_cast<const char *>( uInt32Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::UInt32 ) * cols ) );
191 break;
192 }
194 {
195 std::vector<float> float32Row( cols );
196 for ( int col = 0; col < cols; col++ )
197 {
198 float32Row[col] = static_cast<float>( generateRandomDoubleValue( mersenneTwister ) );
199 }
200 block.setData( QByteArray( reinterpret_cast<const char *>( float32Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Float32 ) * cols ) );
201 break;
202 }
204 {
205 std::vector<double> float64Row( cols );
206 for ( int col = 0; col < cols; col++ )
207 {
208 float64Row[col] = generateRandomDoubleValue( mersenneTwister );
209 }
210 block.setData( QByteArray( reinterpret_cast<const char *>( float64Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Float64 ) * cols ) );
211 break;
212 }
213 default:
214 break;
215 }
216 if ( !provider->writeBlock( &block, 1, 0, row ) )
217 {
218 throw QgsProcessingException( QObject::tr( "Could not write raster block: %1" ).arg( provider->error().summary() ) );
219 }
220 feedback->setProgress( row * step );
221 }
222
223 QVariantMap outputs;
224 outputs.insert( QStringLiteral( "OUTPUT" ), outputFile );
225 return outputs;
226}
227
228//
229//QgsRandomUniformRasterAlgorithm
230//
231QString QgsRandomUniformRasterAlgorithm::name() const
232{
233 return QStringLiteral( "createrandomuniformrasterlayer" );
234}
235
236QString QgsRandomUniformRasterAlgorithm::displayName() const
237{
238 return QObject::tr( "Create random raster layer (uniform distribution)" );
239}
240
241QStringList QgsRandomUniformRasterAlgorithm::tags() const
242{
243 return QObject::tr( "raster,create,random" ).split( ',' );
244}
245
246QString QgsRandomUniformRasterAlgorithm::shortHelpString() const
247{
248 return QObject::tr( "Generates a raster layer for given extent and cell size "
249 "filled with random values.\n"
250 "By default, the values will range between the minimum and "
251 "maximum value of the specified output raster type. This can "
252 "be overridden by using the advanced parameters for lower and "
253 "upper bound value. If the bounds have the same value or both "
254 "are zero (default) the algorithm will create random values in "
255 "the full value range of the chosen raster data type. "
256 "Choosing bounds outside the acceptable range of the output "
257 "raster type will abort the algorithm." );
258}
259
260QgsRandomUniformRasterAlgorithm *QgsRandomUniformRasterAlgorithm::createInstance() const
261{
262 return new QgsRandomUniformRasterAlgorithm();
263}
264
265void QgsRandomUniformRasterAlgorithm::addAlgorithmParams()
266{
267 QStringList rasterDataTypes = QStringList();
268 rasterDataTypes << QStringLiteral( "Byte" )
269 << QStringLiteral( "Integer16" )
270 << QStringLiteral( "Unsigned Integer16" )
271 << QStringLiteral( "Integer32" )
272 << QStringLiteral( "Unsigned Integer32" )
273 << QStringLiteral( "Float32" )
274 << QStringLiteral( "Float64" );
275
276 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 5, false );
277 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
278 addParameter( rasterTypeParameter.release() );
279
280 auto lowerBoundParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "LOWER_BOUND" ), QStringLiteral( "Lower bound for random number range" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
281 lowerBoundParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
282 addParameter( lowerBoundParameter.release() );
283
284 auto upperBoundParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "UPPER_BOUND" ), QStringLiteral( "Upper bound for random number range" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
285 upperBoundParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
286 addParameter( upperBoundParameter.release() );
287}
288
289Qgis::DataType QgsRandomUniformRasterAlgorithm::getRasterDataType( int typeId )
290{
291 switch ( typeId )
292 {
293 case 0:
295 case 1:
297 case 2:
299 case 3:
301 case 4:
303 case 5:
305 case 6:
307 default:
309 }
310}
311
312bool QgsRandomUniformRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
313{
314 mRandomUpperBound = parameterAsDouble( parameters, QStringLiteral( "UPPER_BOUND" ), context );
315 mRandomLowerBound = parameterAsDouble( parameters, QStringLiteral( "LOWER_BOUND" ), context );
316
317 if ( mRandomLowerBound > mRandomUpperBound )
318 throw QgsProcessingException( QObject::tr( "The chosen lower bound for random number range is greater than the upper bound. The lower bound value must be smaller than the upper bound value." ) );
319
320 const int typeId = parameterAsInt( parameters, QStringLiteral( "OUTPUT_TYPE" ), context );
321 const Qgis::DataType rasterDataType = getRasterDataType( typeId );
322
323 switch ( rasterDataType )
324 {
326 if ( mRandomLowerBound < std::numeric_limits<quint8>::min() || mRandomUpperBound > std::numeric_limits<quint8>::max() )
327 throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<quint8>::min() ).arg( std::numeric_limits<quint8>::max() ).arg( QLatin1String( "Byte" ) ) );
328 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
329 {
330 //if parameters unset (=both are 0 or equal) --> use the whole value range
331 mRandomUpperBound = std::numeric_limits<quint8>::max();
332 mRandomLowerBound = std::numeric_limits<quint8>::min();
333 }
334 break;
336 if ( mRandomLowerBound < std::numeric_limits<qint8>::min() || mRandomUpperBound > std::numeric_limits<qint8>::max() )
337 throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<qint8>::min() ).arg( std::numeric_limits<qint8>::max() ).arg( QLatin1String( "Int8" ) ) );
338 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
339 {
340 //if parameters unset (=both are 0 or equal) --> use the whole value range
341 mRandomUpperBound = std::numeric_limits<qint8>::max();
342 mRandomLowerBound = std::numeric_limits<qint8>::min();
343 }
344 break;
346 if ( mRandomLowerBound < std::numeric_limits<qint16>::min() || mRandomUpperBound > std::numeric_limits<qint16>::max() )
347 throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<qint16>::min() ).arg( std::numeric_limits<qint16>::max() ).arg( QLatin1String( "Integer16" ) ) );
348 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
349 {
350 mRandomUpperBound = std::numeric_limits<qint16>::max();
351 mRandomLowerBound = std::numeric_limits<qint16>::min();
352 }
353 break;
355 if ( mRandomLowerBound < std::numeric_limits<quint16>::min() || mRandomUpperBound > std::numeric_limits<quint16>::max() )
356 throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<quint16>::min() ).arg( std::numeric_limits<quint16>::max() ).arg( QLatin1String( "Unsigned Integer16" ) ) );
357 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
358 {
359 mRandomUpperBound = std::numeric_limits<quint16>::max();
360 mRandomLowerBound = std::numeric_limits<quint16>::min();
361 }
362 break;
364 if ( mRandomLowerBound < std::numeric_limits<qint32>::min() || mRandomUpperBound > std::numeric_limits<qint32>::max() )
365 throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<qint32>::min() ).arg( std::numeric_limits<qint32>::max() ).arg( QLatin1String( "Integer32" ) ) );
366 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
367 {
368 mRandomUpperBound = std::numeric_limits<qint32>::max();
369 mRandomLowerBound = std::numeric_limits<qint32>::min();
370 }
371 break;
373 if ( mRandomLowerBound < std::numeric_limits<quint32>::min() || mRandomUpperBound > std::numeric_limits<quint32>::max() )
374 throw QgsProcessingException( QObject::tr( "Raster datasets of type %3 only accept positive values between %1 and %2. Please choose other bounds for random values." ).arg( std::numeric_limits<quint32>::min() ).arg( std::numeric_limits<quint32>::max() ).arg( QLatin1String( "Unsigned Integer32" ) ) );
375 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
376 {
377 mRandomUpperBound = std::numeric_limits<quint32>::max();
378 mRandomLowerBound = std::numeric_limits<quint32>::min();
379 }
380 break;
382 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
383 {
384 mRandomUpperBound = std::numeric_limits<float>::max();
385 mRandomLowerBound = std::numeric_limits<float>::min();
386 }
387 break;
389 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
390 {
391 mRandomUpperBound = std::numeric_limits<double>::max();
392 mRandomLowerBound = std::numeric_limits<double>::min();
393 }
394 break;
402 break;
403 }
404
405 mRandomUniformIntDistribution = std::uniform_int_distribution<long>( mRandomLowerBound, mRandomUpperBound );
406 mRandomUniformDoubleDistribution = std::uniform_real_distribution<double>( mRandomLowerBound, mRandomUpperBound );
407
408 return true;
409}
410
411long QgsRandomUniformRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
412{
413 return mRandomUniformIntDistribution( mersenneTwister );
414}
415
416double QgsRandomUniformRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
417{
418 return mRandomUniformDoubleDistribution( mersenneTwister );
419}
420
421//
422// QgsRandomBinomialRasterAlgorithm
423//
424QString QgsRandomBinomialRasterAlgorithm::name() const
425{
426 return QStringLiteral( "createrandombinomialrasterlayer" );
427}
428
429QString QgsRandomBinomialRasterAlgorithm::displayName() const
430{
431 return QObject::tr( "Create random raster layer (binomial distribution)" );
432}
433
434QStringList QgsRandomBinomialRasterAlgorithm::tags() const
435{
436 return QObject::tr( "raster,create,binomial,random" ).split( ',' );
437}
438
439QString QgsRandomBinomialRasterAlgorithm::shortHelpString() const
440{
441 return QObject::tr( "Generates a raster layer for given extent and cell size "
442 "filled with binomially distributed random values.\n"
443 "By default, the values will be chosen given an N of 10 and a probability of 0.5. "
444 "This can be overridden by using the advanced parameter for N and probability. "
445 "The raster data type is set to Integer types (Integer16 by default). "
446 "The binomial distribution random values are defined as positive integer numbers. "
447 "A floating point raster will represent a cast of integer values "
448 "to floating point." );
449}
450
451QgsRandomBinomialRasterAlgorithm *QgsRandomBinomialRasterAlgorithm::createInstance() const
452{
453 return new QgsRandomBinomialRasterAlgorithm();
454}
455
456
457void QgsRandomBinomialRasterAlgorithm::addAlgorithmParams()
458{
459 QStringList rasterDataTypes = QStringList();
460 rasterDataTypes << QStringLiteral( "Integer16" )
461 << QStringLiteral( "Unsigned Integer16" )
462 << QStringLiteral( "Integer32" )
463 << QStringLiteral( "Unsigned Integer32" )
464 << QStringLiteral( "Float32" )
465 << QStringLiteral( "Float64" );
466
467 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
468 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
469 addParameter( rasterTypeParameter.release() );
470
471 auto nParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "N" ), QStringLiteral( "N" ), Qgis::ProcessingNumberParameterType::Integer, 10, true, 0 );
472 nParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
473 addParameter( nParameter.release() );
474
475 auto probabilityParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "PROBABILITY" ), QStringLiteral( "Probability" ), Qgis::ProcessingNumberParameterType::Double, 0.5, true, 0 );
476 probabilityParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
477 addParameter( probabilityParameter.release() );
478}
479
480Qgis::DataType QgsRandomBinomialRasterAlgorithm::getRasterDataType( int typeId )
481{
482 switch ( typeId )
483 {
484 case 0:
486 case 1:
488 case 2:
490 case 3:
492 case 4:
494 case 5:
496 default:
498 }
499}
500
501bool QgsRandomBinomialRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
502{
503 const int n = parameterAsInt( parameters, QStringLiteral( "N" ), context );
504 const double probability = parameterAsDouble( parameters, QStringLiteral( "PROBABILITY" ), context );
505 mRandombinomialDistribution = std::binomial_distribution<long>( n, probability );
506 return true;
507}
508
509long QgsRandomBinomialRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
510{
511 return mRandombinomialDistribution( mersenneTwister );
512}
513
514double QgsRandomBinomialRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
515{
516 return static_cast<double>( mRandombinomialDistribution( mersenneTwister ) );
517}
518
519//
520// QgsRandomExponentialRasterAlgorithm
521//
522QString QgsRandomExponentialRasterAlgorithm::name() const
523{
524 return QStringLiteral( "createrandomexponentialrasterlayer" );
525}
526
527QString QgsRandomExponentialRasterAlgorithm::displayName() const
528{
529 return QObject::tr( "Create random raster layer (exponential distribution)" );
530}
531
532QStringList QgsRandomExponentialRasterAlgorithm::tags() const
533{
534 return QObject::tr( "raster,create,random,exponential" ).split( ',' );
535}
536
537QString QgsRandomExponentialRasterAlgorithm::shortHelpString() const
538{
539 return QObject::tr( "Generates a raster layer for given extent and cell size "
540 "filled with exponentially distributed random values.\n"
541 "By default, the values will be chosen given a lambda of 1.0. "
542 "This can be overridden by using the advanced parameter for lambda. "
543 "The raster data type is set to Float32 by default as "
544 "the exponential distribution random values are floating point numbers." );
545}
546
547QgsRandomExponentialRasterAlgorithm *QgsRandomExponentialRasterAlgorithm::createInstance() const
548{
549 return new QgsRandomExponentialRasterAlgorithm();
550}
551
552
553void QgsRandomExponentialRasterAlgorithm::addAlgorithmParams()
554{
555 QStringList rasterDataTypes = QStringList();
556 rasterDataTypes << QStringLiteral( "Float32" )
557 << QStringLiteral( "Float64" );
558
559 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
560 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
561 addParameter( rasterTypeParameter.release() );
562
563 auto lambdaParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "LAMBDA" ), QStringLiteral( "Lambda" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0.000001 );
564 lambdaParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
565 addParameter( lambdaParameter.release() );
566}
567
568Qgis::DataType QgsRandomExponentialRasterAlgorithm::getRasterDataType( int typeId )
569{
570 switch ( typeId )
571 {
572 case 0:
574 case 1:
576 default:
578 }
579}
580
581bool QgsRandomExponentialRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
582{
583 const double lambda = parameterAsDouble( parameters, QStringLiteral( "LAMBDA" ), context );
584 mRandomExponentialDistribution = std::exponential_distribution<double>( lambda );
585 return true;
586}
587
588long QgsRandomExponentialRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
589{
590 return static_cast<long>( mRandomExponentialDistribution( mersenneTwister ) );
591}
592
593double QgsRandomExponentialRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
594{
595 return mRandomExponentialDistribution( mersenneTwister );
596}
597
598//
599// QgsRandomGammaRasterAlgorithm
600//
601QString QgsRandomGammaRasterAlgorithm::name() const
602{
603 return QStringLiteral( "createrandomgammarasterlayer" );
604}
605
606QString QgsRandomGammaRasterAlgorithm::displayName() const
607{
608 return QObject::tr( "Create random raster layer (gamma distribution)" );
609}
610
611QStringList QgsRandomGammaRasterAlgorithm::tags() const
612{
613 return QObject::tr( "raster,create,random,gamma" ).split( ',' );
614}
615
616QString QgsRandomGammaRasterAlgorithm::shortHelpString() const
617{
618 return QObject::tr( "Generates a raster layer for given extent and cell size "
619 "filled with gamma distributed random values.\n"
620 "By default, the values will be chosen given an alpha and beta value of 1.0. "
621 "This can be overridden by using the advanced parameter for alpha and beta. "
622 "The raster data type is set to Float32 by default as "
623 "the gamma distribution random values are floating point numbers." );
624}
625
626QgsRandomGammaRasterAlgorithm *QgsRandomGammaRasterAlgorithm::createInstance() const
627{
628 return new QgsRandomGammaRasterAlgorithm();
629}
630
631
632void QgsRandomGammaRasterAlgorithm::addAlgorithmParams()
633{
634 QStringList rasterDataTypes = QStringList();
635 rasterDataTypes << QStringLiteral( "Float32" )
636 << QStringLiteral( "Float64" );
637
638 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
639 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
640 addParameter( rasterTypeParameter.release() );
641
642 auto alphaParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "ALPHA" ), QStringLiteral( "Alpha" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0.000001 );
643 alphaParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
644 addParameter( alphaParameter.release() );
645
646 auto betaParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "BETA" ), QStringLiteral( "Beta" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0.000001 );
647 betaParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
648 addParameter( betaParameter.release() );
649}
650
651Qgis::DataType QgsRandomGammaRasterAlgorithm::getRasterDataType( int typeId )
652{
653 switch ( typeId )
654 {
655 case 0:
657 case 1:
659 default:
661 }
662}
663
664bool QgsRandomGammaRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
665{
666 const double alpha = parameterAsDouble( parameters, QStringLiteral( "ALPHA" ), context );
667 const double beta = parameterAsDouble( parameters, QStringLiteral( "BETA" ), context );
668 mRandomGammaDistribution = std::gamma_distribution<double>( alpha, beta );
669 return true;
670}
671
672long QgsRandomGammaRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
673{
674 return static_cast<long>( mRandomGammaDistribution( mersenneTwister ) );
675}
676
677double QgsRandomGammaRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
678{
679 return mRandomGammaDistribution( mersenneTwister );
680}
681
682//
683// QgsRandomGeometricRasterAlgorithm
684//
685QString QgsRandomGeometricRasterAlgorithm::name() const
686{
687 return QStringLiteral( "createrandomgeometricrasterlayer" );
688}
689
690QString QgsRandomGeometricRasterAlgorithm::displayName() const
691{
692 return QObject::tr( "Create random raster layer (geometric distribution)" );
693}
694
695QStringList QgsRandomGeometricRasterAlgorithm::tags() const
696{
697 return QObject::tr( "raster,create,random,geometric" ).split( ',' );
698}
699
700QString QgsRandomGeometricRasterAlgorithm::shortHelpString() const
701{
702 return QObject::tr( "Generates a raster layer for given extent and cell size "
703 "filled with geometrically distributed random values.\n"
704 "By default, the values will be chosen given a probability of 0.5. "
705 "This can be overridden by using the advanced parameter for mean "
706 "value. The raster data type is set to Integer types (Integer16 by default). "
707 "The geometric distribution random values are defined as positive integer numbers. "
708 "A floating point raster will represent a cast of "
709 "integer values to floating point." );
710}
711
712QgsRandomGeometricRasterAlgorithm *QgsRandomGeometricRasterAlgorithm::createInstance() const
713{
714 return new QgsRandomGeometricRasterAlgorithm();
715}
716
717
718void QgsRandomGeometricRasterAlgorithm::addAlgorithmParams()
719{
720 QStringList rasterDataTypes = QStringList();
721 rasterDataTypes << QStringLiteral( "Integer16" )
722 << QStringLiteral( "Unsigned Integer16" )
723 << QStringLiteral( "Integer32" )
724 << QStringLiteral( "Unsigned Integer32" )
725 << QStringLiteral( "Float32" )
726 << QStringLiteral( "Float64" );
727
728 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
729 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
730 addParameter( rasterTypeParameter.release() );
731
732 auto probabilityParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "PROBABILITY" ), QStringLiteral( "Probability" ), Qgis::ProcessingNumberParameterType::Double, 0.5, true, 0.00001 );
733 probabilityParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
734 addParameter( probabilityParameter.release() );
735}
736
737Qgis::DataType QgsRandomGeometricRasterAlgorithm::getRasterDataType( int typeId )
738{
739 switch ( typeId )
740 {
741 case 0:
743 case 1:
745 case 2:
747 case 3:
749 case 4:
751 case 5:
753 default:
755 }
756}
757
758bool QgsRandomGeometricRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
759{
760 const double probability = parameterAsDouble( parameters, QStringLiteral( "PROBABILITY" ), context );
761 mRandomGeometricDistribution = std::geometric_distribution<long>( probability );
762 return true;
763}
764
765long QgsRandomGeometricRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
766{
767 return mRandomGeometricDistribution( mersenneTwister );
768}
769
770double QgsRandomGeometricRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
771{
772 return static_cast<double>( mRandomGeometricDistribution( mersenneTwister ) );
773}
774
775//
776// QgsRandomNegativeBinomialRasterAlgorithm
777//
778QString QgsRandomNegativeBinomialRasterAlgorithm::name() const
779{
780 return QStringLiteral( "createrandomnegativebinomialrasterlayer" );
781}
782
783QString QgsRandomNegativeBinomialRasterAlgorithm::displayName() const
784{
785 return QObject::tr( "Create random raster layer (negative binomial distribution)" );
786}
787
788QStringList QgsRandomNegativeBinomialRasterAlgorithm::tags() const
789{
790 return QObject::tr( "raster,create,random,negative,binomial,negative-binomial" ).split( ',' );
791}
792
793QString QgsRandomNegativeBinomialRasterAlgorithm::shortHelpString() const
794{
795 return QObject::tr( "Generates a raster layer for given extent and cell size "
796 "filled with negative binomially distributed random values.\n"
797 "By default, the values will be chosen given a distribution parameter k of 10.0 "
798 "and a probability of 0.5. "
799 "This can be overridden by using the advanced parameters for k and probability. "
800 "The raster data type is set to Integer types (Integer 16 by default). "
801 "The negative binomial distribution random values are defined as positive integer numbers. "
802 "A floating point raster will represent a cast of "
803 "integer values to floating point." );
804}
805
806QgsRandomNegativeBinomialRasterAlgorithm *QgsRandomNegativeBinomialRasterAlgorithm::createInstance() const
807{
808 return new QgsRandomNegativeBinomialRasterAlgorithm();
809}
810
811
812void QgsRandomNegativeBinomialRasterAlgorithm::addAlgorithmParams()
813{
814 QStringList rasterDataTypes = QStringList();
815 rasterDataTypes << QStringLiteral( "Integer16" )
816 << QStringLiteral( "Unsigned Integer16" )
817 << QStringLiteral( "Integer32" )
818 << QStringLiteral( "Unsigned Integer32" )
819 << QStringLiteral( "Float32" )
820 << QStringLiteral( "Float64" );
821
822 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
823 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
824 addParameter( rasterTypeParameter.release() );
825
826 auto kParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "K_PARAMETER" ), QStringLiteral( "Distribution parameter k" ), Qgis::ProcessingNumberParameterType::Integer, 10, true, 0.00001 );
827 kParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
828 addParameter( kParameter.release() );
829
830 auto probabilityParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "PROBABILITY" ), QStringLiteral( "Probability" ), Qgis::ProcessingNumberParameterType::Double, 0.5, true, 0.00001 );
831 probabilityParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
832 addParameter( probabilityParameter.release() );
833}
834
835Qgis::DataType QgsRandomNegativeBinomialRasterAlgorithm::getRasterDataType( int typeId )
836{
837 switch ( typeId )
838 {
839 case 0:
841 case 1:
843 case 2:
845 case 3:
847 case 4:
849 case 5:
851 default:
853 }
854}
855
856bool QgsRandomNegativeBinomialRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
857{
858 const int k = parameterAsInt( parameters, QStringLiteral( "K_PARAMETER" ), context );
859 const double probability = parameterAsDouble( parameters, QStringLiteral( "PROBABILITY" ), context );
860 mRandomNegativeBinomialDistribution = std::negative_binomial_distribution<long>( k, probability );
861 return true;
862}
863
864long QgsRandomNegativeBinomialRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
865{
866 return mRandomNegativeBinomialDistribution( mersenneTwister );
867}
868
869double QgsRandomNegativeBinomialRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
870{
871 return static_cast<double>( mRandomNegativeBinomialDistribution( mersenneTwister ) );
872}
873
874//
875// QgsRandomNormalRasterAlgorithm
876//
877QString QgsRandomNormalRasterAlgorithm::name() const
878{
879 return QStringLiteral( "createrandomnormalrasterlayer" );
880}
881
882QString QgsRandomNormalRasterAlgorithm::displayName() const
883{
884 return QObject::tr( "Create random raster layer (normal distribution)" );
885}
886
887QStringList QgsRandomNormalRasterAlgorithm::tags() const
888{
889 return QObject::tr( "raster,create,normal,distribution,random" ).split( ',' );
890}
891
892QString QgsRandomNormalRasterAlgorithm::shortHelpString() const
893{
894 return QObject::tr( "Generates a raster layer for given extent and cell size "
895 "filled with normally distributed random values.\n"
896 "By default, the values will be chosen given a mean of 0.0 and "
897 "a standard deviation of 1.0. This can be overridden by "
898 "using the advanced parameters for mean and standard deviation "
899 "value. The raster data type is set to Float32 by default "
900 "as the normal distribution random values are floating point numbers." );
901}
902
903QgsRandomNormalRasterAlgorithm *QgsRandomNormalRasterAlgorithm::createInstance() const
904{
905 return new QgsRandomNormalRasterAlgorithm();
906}
907
908void QgsRandomNormalRasterAlgorithm::addAlgorithmParams()
909{
910 QStringList rasterDataTypes = QStringList();
911 rasterDataTypes << QStringLiteral( "Float32" )
912 << QStringLiteral( "Float64" );
913
914 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
915 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
916 addParameter( rasterTypeParameter.release() );
917
918 auto meanParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "MEAN" ), QStringLiteral( "Mean of normal distribution" ), Qgis::ProcessingNumberParameterType::Double, 0, true );
919 meanParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
920 addParameter( meanParameter.release() );
921
922 auto stdevParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "STDDEV" ), QStringLiteral( "Standard deviation of normal distribution" ), Qgis::ProcessingNumberParameterType::Double, 1, true, 0 );
923 stdevParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
924 addParameter( stdevParameter.release() );
925}
926
927Qgis::DataType QgsRandomNormalRasterAlgorithm::getRasterDataType( int typeId )
928{
929 switch ( typeId )
930 {
931 case 0:
933 case 1:
935 default:
937 }
938}
939
940bool QgsRandomNormalRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
941{
942 const double mean = parameterAsDouble( parameters, QStringLiteral( "MEAN" ), context );
943 const double stddev = parameterAsDouble( parameters, QStringLiteral( "STDDEV" ), context );
944 mRandomNormalDistribution = std::normal_distribution<double>( mean, stddev );
945 return true;
946}
947
948long QgsRandomNormalRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
949{
950 return static_cast<long>( mRandomNormalDistribution( mersenneTwister ) );
951}
952
953double QgsRandomNormalRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
954{
955 return mRandomNormalDistribution( mersenneTwister );
956}
957
958//
959// QgsRandomPoissonRasterAlgorithm
960//
961QString QgsRandomPoissonRasterAlgorithm::name() const
962{
963 return QStringLiteral( "createrandompoissonrasterlayer" );
964}
965
966QString QgsRandomPoissonRasterAlgorithm::displayName() const
967{
968 return QObject::tr( "Create random raster layer (poisson distribution)" );
969}
970
971QStringList QgsRandomPoissonRasterAlgorithm::tags() const
972{
973 return QObject::tr( "raster,create,random,poisson" ).split( ',' );
974}
975
976QString QgsRandomPoissonRasterAlgorithm::shortHelpString() const
977{
978 return QObject::tr( "Generates a raster layer for given extent and cell size "
979 "filled with poisson distributed random values.\n"
980 "By default, the values will be chosen given a mean of 1.0. "
981 "This can be overridden by using the advanced parameter for mean "
982 "value. The raster data type is set to Integer types (Integer16 by default). "
983 "The poisson distribution random values are positive integer numbers. "
984 "A floating point raster will represent a cast of integer values to floating point." );
985}
986
987QgsRandomPoissonRasterAlgorithm *QgsRandomPoissonRasterAlgorithm::createInstance() const
988{
989 return new QgsRandomPoissonRasterAlgorithm();
990}
991
992
993void QgsRandomPoissonRasterAlgorithm::addAlgorithmParams()
994{
995 QStringList rasterDataTypes = QStringList();
996 rasterDataTypes << QStringLiteral( "Integer16" )
997 << QStringLiteral( "Unsigned Integer16" )
998 << QStringLiteral( "Integer32" )
999 << QStringLiteral( "Unsigned Integer32" )
1000 << QStringLiteral( "Float32" )
1001 << QStringLiteral( "Float64" );
1002
1003 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
1004 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
1005 addParameter( rasterTypeParameter.release() );
1006
1007 auto upperBoundParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "MEAN" ), QStringLiteral( "Mean" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0 );
1008 upperBoundParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
1009 addParameter( upperBoundParameter.release() );
1010}
1011
1012Qgis::DataType QgsRandomPoissonRasterAlgorithm::getRasterDataType( int typeId )
1013{
1014 switch ( typeId )
1015 {
1016 case 0:
1017 return Qgis::DataType::Int16;
1018 case 1:
1020 case 2:
1021 return Qgis::DataType::Int32;
1022 case 3:
1024 case 4:
1026 case 5:
1028 default:
1030 }
1031}
1032
1033bool QgsRandomPoissonRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
1034{
1035 const double mean = parameterAsDouble( parameters, QStringLiteral( "MEAN" ), context );
1036 mRandomPoissonDistribution = std::poisson_distribution<long>( mean );
1037 return true;
1038}
1039
1040long QgsRandomPoissonRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
1041{
1042 return mRandomPoissonDistribution( mersenneTwister );
1043}
1044
1045double QgsRandomPoissonRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
1046{
1047 return static_cast<double>( mRandomPoissonDistribution( mersenneTwister ) );
1048}
1049
DataType
Raster data types.
Definition qgis.h:351
@ CInt32
Complex Int32.
@ Float32
Thirty two bit floating point (float)
@ CFloat64
Complex Float64.
@ Int16
Sixteen bit signed integer (qint16)
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30)
@ UInt16
Sixteen bit unsigned integer (quint16)
@ Byte
Eight bit unsigned integer (quint8)
@ UnknownDataType
Unknown or unspecified type.
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
@ Int32
Thirty two bit signed integer (qint32)
@ Float64
Sixty four bit floating point (double)
@ CFloat32
Complex Float32.
@ CInt16
Complex Int16.
@ UInt32
Thirty two bit unsigned integer (quint32)
@ Hidden
Parameter is hidden and should not be shown to users.
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
bool isCanceled() const
Tells whether the operation has been canceled already.
Definition qgsfeedback.h:53
void setProgress(double progress)
Sets the current progress for the feedback object.
Definition qgsfeedback.h:61
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 coordinate reference system parameter for processing algorithms.
A rectangular map extent parameter for processing algorithms.
A numeric parameter for processing algorithms.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
Raster data container.
static int typeSize(Qgis::DataType dataType)
Returns the size in bytes for the specified dataType.
static QString driverForExtension(const QString &extension)
Returns the GDAL driver name for a specified file extension.
A rectangle specified with double values.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:6287