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