QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#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 std::unique_ptr<QgsProcessingParameterString> createOptsParam = std::make_unique<QgsProcessingParameterString>( QStringLiteral( "CREATE_OPTIONS" ), QObject::tr( "Creation options" ), QVariant(), false, true );
49 createOptsParam->setMetadata( QVariantMap( { { QStringLiteral( "widget_wrapper" ), QVariantMap( { { QStringLiteral( "widget_type" ), QStringLiteral( "rasteroptions" ) } } ) } } ) );
50 createOptsParam->setFlags( createOptsParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
51 addParameter( createOptsParam.release() );
52
53 addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output raster" ) ) );
54}
55
56bool QgsRandomRasterAlgorithmBase::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
57{
58 Q_UNUSED( feedback );
59 mCrs = parameterAsCrs( parameters, QStringLiteral( "TARGET_CRS" ), context );
60 mExtent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context, mCrs );
61 mPixelSize = parameterAsDouble( parameters, QStringLiteral( "PIXEL_SIZE" ), context );
62
63 if ( mPixelSize <= 0 )
64 {
65 throw QgsProcessingException( QObject::tr( "Pixel size must be greater than 0." ) );
66 }
67
68 return true;
69}
70
71QVariantMap QgsRandomRasterAlgorithmBase::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
72{
73 const int typeId = parameterAsInt( parameters, QStringLiteral( "OUTPUT_TYPE" ), context );
74 //prepare specific parameters
75 mRasterDataType = getRasterDataType( typeId );
76 prepareRandomParameters( parameters, context );
77
78 std::random_device rd {};
79 std::mt19937 mersenneTwister { rd() };
80
81 const QString createOptions = parameterAsString( parameters, QStringLiteral( "CREATE_OPTIONS" ), context ).trimmed();
82 const QString outputFile = parameterAsOutputLayer( parameters, QStringLiteral( "OUTPUT" ), context );
83 const QFileInfo fi( outputFile );
84 const QString outputFormat = QgsRasterFileWriter::driverForExtension( fi.suffix() );
85
86 const int rows = std::max( std::ceil( mExtent.height() / mPixelSize ), 1.0 );
87 const int cols = std::max( std::ceil( mExtent.width() / mPixelSize ), 1.0 );
88
89 //build new raster extent based on number of columns and cellsize
90 //this prevents output cellsize being calculated too small
91 const QgsRectangle rasterExtent = QgsRectangle( mExtent.xMinimum(), mExtent.yMaximum() - ( rows * mPixelSize ), mExtent.xMinimum() + ( cols * mPixelSize ), mExtent.yMaximum() );
92
93 std::unique_ptr<QgsRasterFileWriter> writer = std::make_unique<QgsRasterFileWriter>( outputFile );
94 writer->setOutputProviderKey( QStringLiteral( "gdal" ) );
95 if ( !createOptions.isEmpty() )
96 {
97 writer->setCreateOptions( createOptions.split( '|' ) );
98 }
99
100 writer->setOutputFormat( outputFormat );
101 std::unique_ptr<QgsRasterDataProvider> provider( writer->createOneBandRaster( mRasterDataType, cols, rows, rasterExtent, mCrs ) );
102 if ( !provider )
103 throw QgsProcessingException( QObject::tr( "Could not create raster output: %1" ).arg( outputFile ) );
104 if ( !provider->isValid() )
105 throw QgsProcessingException( QObject::tr( "Could not create raster output %1: %2" ).arg( outputFile, provider->error().message( QgsErrorMessage::Text ) ) );
106
107 const double step = rows > 0 ? 100.0 / rows : 1;
108
109 for ( int row = 0; row < rows; row++ )
110 {
111 if ( feedback->isCanceled() )
112 {
113 break;
114 }
115 //prepare raw data depending on raster data type
116 QgsRasterBlock block( mRasterDataType, cols, 1 );
117 switch ( mRasterDataType )
118 {
120 {
121 std::vector<quint8> byteRow( cols );
122 for ( int col = 0; col < cols; col++ )
123 {
124 byteRow[col] = static_cast<quint8>( generateRandomLongValue( mersenneTwister ) );
125 }
126 block.setData( QByteArray( reinterpret_cast<const char *>( byteRow.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Byte ) * cols ) );
127 break;
128 }
130 {
131 std::vector<qint8> int8Row( cols );
132 for ( int col = 0; col < cols; col++ )
133 {
134 int8Row[col] = static_cast<qint8>( generateRandomLongValue( mersenneTwister ) );
135 }
136 block.setData( QByteArray( reinterpret_cast<const char *>( int8Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Int8 ) * cols ) );
137 break;
138 }
140 {
141 std::vector<qint16> int16Row( cols );
142 for ( int col = 0; col < cols; col++ )
143 {
144 int16Row[col] = static_cast<qint16>( generateRandomLongValue( mersenneTwister ) );
145 }
146 block.setData( QByteArray( reinterpret_cast<const char *>( int16Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Int16 ) * cols ) );
147 break;
148 }
150 {
151 std::vector<quint16> uInt16Row( cols );
152 for ( int col = 0; col < cols; col++ )
153 {
154 uInt16Row[col] = static_cast<quint16>( generateRandomLongValue( mersenneTwister ) );
155 }
156 block.setData( QByteArray( reinterpret_cast<const char *>( uInt16Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::UInt16 ) * cols ) );
157 break;
158 }
160 {
161 std::vector<qint32> int32Row( cols );
162 for ( int col = 0; col < cols; col++ )
163 {
164 int32Row[col] = generateRandomLongValue( mersenneTwister );
165 }
166 block.setData( QByteArray( reinterpret_cast<const char *>( int32Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Int32 ) * cols ) );
167 break;
168 }
170 {
171 std::vector<quint32> uInt32Row( cols );
172 for ( int col = 0; col < cols; col++ )
173 {
174 uInt32Row[col] = static_cast<quint32>( generateRandomLongValue( mersenneTwister ) );
175 }
176 block.setData( QByteArray( reinterpret_cast<const char *>( uInt32Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::UInt32 ) * cols ) );
177 break;
178 }
180 {
181 std::vector<float> float32Row( cols );
182 for ( int col = 0; col < cols; col++ )
183 {
184 float32Row[col] = static_cast<float>( generateRandomDoubleValue( mersenneTwister ) );
185 }
186 block.setData( QByteArray( reinterpret_cast<const char *>( float32Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Float32 ) * cols ) );
187 break;
188 }
190 {
191 std::vector<double> float64Row( cols );
192 for ( int col = 0; col < cols; col++ )
193 {
194 float64Row[col] = generateRandomDoubleValue( mersenneTwister );
195 }
196 block.setData( QByteArray( reinterpret_cast<const char *>( float64Row.data() ), QgsRasterBlock::typeSize( Qgis::DataType::Float64 ) * cols ) );
197 break;
198 }
199 default:
200 break;
201 }
202 provider->writeBlock( &block, 1, 0, row );
203 feedback->setProgress( row * step );
204 }
205
206 QVariantMap outputs;
207 outputs.insert( QStringLiteral( "OUTPUT" ), outputFile );
208 return outputs;
209}
210
211//
212//QgsRandomUniformRasterAlgorithm
213//
214QString QgsRandomUniformRasterAlgorithm::name() const
215{
216 return QStringLiteral( "createrandomuniformrasterlayer" );
217}
218
219QString QgsRandomUniformRasterAlgorithm::displayName() const
220{
221 return QObject::tr( "Create random raster layer (uniform distribution)" );
222}
223
224QStringList QgsRandomUniformRasterAlgorithm::tags() const
225{
226 return QObject::tr( "raster,create,random" ).split( ',' );
227}
228
229QString QgsRandomUniformRasterAlgorithm::shortHelpString() const
230{
231 return QObject::tr( "Generates a raster layer for given extent and cell size "
232 "filled with random values.\n"
233 "By default, the values will range between the minimum and "
234 "maximum value of the specified output raster type. This can "
235 "be overridden by using the advanced parameters for lower and "
236 "upper bound value. If the bounds have the same value or both "
237 "are zero (default) the algorithm will create random values in "
238 "the full value range of the chosen raster data type. "
239 "Choosing bounds outside the acceptable range of the output "
240 "raster type will abort the algorithm." );
241}
242
243QgsRandomUniformRasterAlgorithm *QgsRandomUniformRasterAlgorithm::createInstance() const
244{
245 return new QgsRandomUniformRasterAlgorithm();
246}
247
248void QgsRandomUniformRasterAlgorithm::addAlgorithmParams()
249{
250 QStringList rasterDataTypes = QStringList();
251 rasterDataTypes << QStringLiteral( "Byte" )
252 << QStringLiteral( "Integer16" )
253 << QStringLiteral( "Unsigned Integer16" )
254 << QStringLiteral( "Integer32" )
255 << QStringLiteral( "Unsigned Integer32" )
256 << QStringLiteral( "Float32" )
257 << QStringLiteral( "Float64" );
258
259 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 5, false );
260 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
261 addParameter( rasterTypeParameter.release() );
262
263 std::unique_ptr<QgsProcessingParameterNumber> lowerBoundParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "LOWER_BOUND" ), QStringLiteral( "Lower bound for random number range" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
264 lowerBoundParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
265 addParameter( lowerBoundParameter.release() );
266
267 std::unique_ptr<QgsProcessingParameterNumber> upperBoundParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "UPPER_BOUND" ), QStringLiteral( "Upper bound for random number range" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
268 upperBoundParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
269 addParameter( upperBoundParameter.release() );
270}
271
272Qgis::DataType QgsRandomUniformRasterAlgorithm::getRasterDataType( int typeId )
273{
274 switch ( typeId )
275 {
276 case 0:
278 case 1:
280 case 2:
282 case 3:
284 case 4:
286 case 5:
288 case 6:
290 default:
292 }
293}
294
295bool QgsRandomUniformRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
296{
297 mRandomUpperBound = parameterAsDouble( parameters, QStringLiteral( "UPPER_BOUND" ), context );
298 mRandomLowerBound = parameterAsDouble( parameters, QStringLiteral( "LOWER_BOUND" ), context );
299
300 if ( mRandomLowerBound > mRandomUpperBound )
301 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." ) );
302
303 const int typeId = parameterAsInt( parameters, QStringLiteral( "OUTPUT_TYPE" ), context );
304 const Qgis::DataType rasterDataType = getRasterDataType( typeId );
305
306 switch ( rasterDataType )
307 {
309 if ( mRandomLowerBound < std::numeric_limits<quint8>::min() || mRandomUpperBound > std::numeric_limits<quint8>::max() )
310 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" ) ) );
311 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
312 {
313 //if parameters unset (=both are 0 or equal) --> use the whole value range
314 mRandomUpperBound = std::numeric_limits<quint8>::max();
315 mRandomLowerBound = std::numeric_limits<quint8>::min();
316 }
317 break;
319 if ( mRandomLowerBound < std::numeric_limits<qint8>::min() || mRandomUpperBound > std::numeric_limits<qint8>::max() )
320 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" ) ) );
321 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
322 {
323 //if parameters unset (=both are 0 or equal) --> use the whole value range
324 mRandomUpperBound = std::numeric_limits<qint8>::max();
325 mRandomLowerBound = std::numeric_limits<qint8>::min();
326 }
327 break;
329 if ( mRandomLowerBound < std::numeric_limits<qint16>::min() || mRandomUpperBound > std::numeric_limits<qint16>::max() )
330 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" ) ) );
331 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
332 {
333 mRandomUpperBound = std::numeric_limits<qint16>::max();
334 mRandomLowerBound = std::numeric_limits<qint16>::min();
335 }
336 break;
338 if ( mRandomLowerBound < std::numeric_limits<quint16>::min() || mRandomUpperBound > std::numeric_limits<quint16>::max() )
339 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" ) ) );
340 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
341 {
342 mRandomUpperBound = std::numeric_limits<quint16>::max();
343 mRandomLowerBound = std::numeric_limits<quint16>::min();
344 }
345 break;
347 if ( mRandomLowerBound < std::numeric_limits<qint32>::min() || mRandomUpperBound > std::numeric_limits<qint32>::max() )
348 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" ) ) );
349 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
350 {
351 mRandomUpperBound = std::numeric_limits<qint32>::max();
352 mRandomLowerBound = std::numeric_limits<qint32>::min();
353 }
354 break;
356 if ( mRandomLowerBound < std::numeric_limits<quint32>::min() || mRandomUpperBound > std::numeric_limits<quint32>::max() )
357 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" ) ) );
358 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
359 {
360 mRandomUpperBound = std::numeric_limits<quint32>::max();
361 mRandomLowerBound = std::numeric_limits<quint32>::min();
362 }
363 break;
365 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
366 {
367 mRandomUpperBound = std::numeric_limits<float>::max();
368 mRandomLowerBound = std::numeric_limits<float>::min();
369 }
370 break;
372 if ( ( qgsDoubleNear( mRandomLowerBound, 0.0 ) && qgsDoubleNear( mRandomUpperBound, 0.0 ) ) || qgsDoubleNear( mRandomUpperBound, mRandomLowerBound ) )
373 {
374 mRandomUpperBound = std::numeric_limits<double>::max();
375 mRandomLowerBound = std::numeric_limits<double>::min();
376 }
377 break;
385 break;
386 }
387
388 mRandomUniformIntDistribution = std::uniform_int_distribution<long>( mRandomLowerBound, mRandomUpperBound );
389 mRandomUniformDoubleDistribution = std::uniform_real_distribution<double>( mRandomLowerBound, mRandomUpperBound );
390
391 return true;
392}
393
394long QgsRandomUniformRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
395{
396 return mRandomUniformIntDistribution( mersenneTwister );
397}
398
399double QgsRandomUniformRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
400{
401 return mRandomUniformDoubleDistribution( mersenneTwister );
402}
403
404//
405// QgsRandomBinomialRasterAlgorithm
406//
407QString QgsRandomBinomialRasterAlgorithm::name() const
408{
409 return QStringLiteral( "createrandombinomialrasterlayer" );
410}
411
412QString QgsRandomBinomialRasterAlgorithm::displayName() const
413{
414 return QObject::tr( "Create random raster layer (binomial distribution)" );
415}
416
417QStringList QgsRandomBinomialRasterAlgorithm::tags() const
418{
419 return QObject::tr( "raster,create,binomial,random" ).split( ',' );
420}
421
422QString QgsRandomBinomialRasterAlgorithm::shortHelpString() const
423{
424 return QObject::tr( "Generates a raster layer for given extent and cell size "
425 "filled with binomially distributed random values.\n"
426 "By default, the values will be chosen given an N of 10 and a probability of 0.5. "
427 "This can be overridden by using the advanced parameter for N and probability. "
428 "The raster data type is set to Integer types (Integer16 by default). "
429 "The binomial distribution random values are defined as positive integer numbers. "
430 "A floating point raster will represent a cast of integer values "
431 "to floating point." );
432}
433
434QgsRandomBinomialRasterAlgorithm *QgsRandomBinomialRasterAlgorithm::createInstance() const
435{
436 return new QgsRandomBinomialRasterAlgorithm();
437}
438
439
440void QgsRandomBinomialRasterAlgorithm::addAlgorithmParams()
441{
442 QStringList rasterDataTypes = QStringList();
443 rasterDataTypes << QStringLiteral( "Integer16" )
444 << QStringLiteral( "Unsigned Integer16" )
445 << QStringLiteral( "Integer32" )
446 << QStringLiteral( "Unsigned Integer32" )
447 << QStringLiteral( "Float32" )
448 << QStringLiteral( "Float64" );
449
450 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
451 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
452 addParameter( rasterTypeParameter.release() );
453
454 std::unique_ptr<QgsProcessingParameterNumber> nParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "N" ), QStringLiteral( "N" ), Qgis::ProcessingNumberParameterType::Integer, 10, true, 0 );
455 nParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
456 addParameter( nParameter.release() );
457
458 std::unique_ptr<QgsProcessingParameterNumber> probabilityParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "PROBABILITY" ), QStringLiteral( "Probability" ), Qgis::ProcessingNumberParameterType::Double, 0.5, true, 0 );
459 probabilityParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
460 addParameter( probabilityParameter.release() );
461}
462
463Qgis::DataType QgsRandomBinomialRasterAlgorithm::getRasterDataType( int typeId )
464{
465 switch ( typeId )
466 {
467 case 0:
469 case 1:
471 case 2:
473 case 3:
475 case 4:
477 case 5:
479 default:
481 }
482}
483
484bool QgsRandomBinomialRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
485{
486 const int n = parameterAsInt( parameters, QStringLiteral( "N" ), context );
487 const double probability = parameterAsDouble( parameters, QStringLiteral( "PROBABILITY" ), context );
488 mRandombinomialDistribution = std::binomial_distribution<long>( n, probability );
489 return true;
490}
491
492long QgsRandomBinomialRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
493{
494 return mRandombinomialDistribution( mersenneTwister );
495}
496
497double QgsRandomBinomialRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
498{
499 return static_cast<double>( mRandombinomialDistribution( mersenneTwister ) );
500}
501
502//
503// QgsRandomExponentialRasterAlgorithm
504//
505QString QgsRandomExponentialRasterAlgorithm::name() const
506{
507 return QStringLiteral( "createrandomexponentialrasterlayer" );
508}
509
510QString QgsRandomExponentialRasterAlgorithm::displayName() const
511{
512 return QObject::tr( "Create random raster layer (exponential distribution)" );
513}
514
515QStringList QgsRandomExponentialRasterAlgorithm::tags() const
516{
517 return QObject::tr( "raster,create,random,exponential" ).split( ',' );
518}
519
520QString QgsRandomExponentialRasterAlgorithm::shortHelpString() const
521{
522 return QObject::tr( "Generates a raster layer for given extent and cell size "
523 "filled with exponentially distributed random values.\n"
524 "By default, the values will be chosen given a lambda of 1.0. "
525 "This can be overridden by using the advanced parameter for lambda. "
526 "The raster data type is set to Float32 by default as "
527 "the exponential distribution random values are floating point numbers." );
528}
529
530QgsRandomExponentialRasterAlgorithm *QgsRandomExponentialRasterAlgorithm::createInstance() const
531{
532 return new QgsRandomExponentialRasterAlgorithm();
533}
534
535
536void QgsRandomExponentialRasterAlgorithm::addAlgorithmParams()
537{
538 QStringList rasterDataTypes = QStringList();
539 rasterDataTypes << QStringLiteral( "Float32" )
540 << QStringLiteral( "Float64" );
541
542 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
543 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
544 addParameter( rasterTypeParameter.release() );
545
546 std::unique_ptr<QgsProcessingParameterNumber> lambdaParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "LAMBDA" ), QStringLiteral( "Lambda" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0.000001 );
547 lambdaParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
548 addParameter( lambdaParameter.release() );
549}
550
551Qgis::DataType QgsRandomExponentialRasterAlgorithm::getRasterDataType( int typeId )
552{
553 switch ( typeId )
554 {
555 case 0:
557 case 1:
559 default:
561 }
562}
563
564bool QgsRandomExponentialRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
565{
566 const double lambda = parameterAsDouble( parameters, QStringLiteral( "LAMBDA" ), context );
567 mRandomExponentialDistribution = std::exponential_distribution<double>( lambda );
568 return true;
569}
570
571long QgsRandomExponentialRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
572{
573 return static_cast<long>( mRandomExponentialDistribution( mersenneTwister ) );
574}
575
576double QgsRandomExponentialRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
577{
578 return mRandomExponentialDistribution( mersenneTwister );
579}
580
581//
582// QgsRandomGammaRasterAlgorithm
583//
584QString QgsRandomGammaRasterAlgorithm::name() const
585{
586 return QStringLiteral( "createrandomgammarasterlayer" );
587}
588
589QString QgsRandomGammaRasterAlgorithm::displayName() const
590{
591 return QObject::tr( "Create random raster layer (gamma distribution)" );
592}
593
594QStringList QgsRandomGammaRasterAlgorithm::tags() const
595{
596 return QObject::tr( "raster,create,random,gamma" ).split( ',' );
597}
598
599QString QgsRandomGammaRasterAlgorithm::shortHelpString() const
600{
601 return QObject::tr( "Generates a raster layer for given extent and cell size "
602 "filled with gamma distributed random values.\n"
603 "By default, the values will be chosen given an alpha and beta value of 1.0. "
604 "This can be overridden by using the advanced parameter for alpha and beta. "
605 "The raster data type is set to Float32 by default as "
606 "the gamma distribution random values are floating point numbers." );
607}
608
609QgsRandomGammaRasterAlgorithm *QgsRandomGammaRasterAlgorithm::createInstance() const
610{
611 return new QgsRandomGammaRasterAlgorithm();
612}
613
614
615void QgsRandomGammaRasterAlgorithm::addAlgorithmParams()
616{
617 QStringList rasterDataTypes = QStringList();
618 rasterDataTypes << QStringLiteral( "Float32" )
619 << QStringLiteral( "Float64" );
620
621 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
622 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
623 addParameter( rasterTypeParameter.release() );
624
625 std::unique_ptr<QgsProcessingParameterNumber> alphaParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "ALPHA" ), QStringLiteral( "Alpha" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0.000001 );
626 alphaParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
627 addParameter( alphaParameter.release() );
628
629 std::unique_ptr<QgsProcessingParameterNumber> betaParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "BETA" ), QStringLiteral( "Beta" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0.000001 );
630 betaParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
631 addParameter( betaParameter.release() );
632}
633
634Qgis::DataType QgsRandomGammaRasterAlgorithm::getRasterDataType( int typeId )
635{
636 switch ( typeId )
637 {
638 case 0:
640 case 1:
642 default:
644 }
645}
646
647bool QgsRandomGammaRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
648{
649 const double alpha = parameterAsDouble( parameters, QStringLiteral( "ALPHA" ), context );
650 const double beta = parameterAsDouble( parameters, QStringLiteral( "BETA" ), context );
651 mRandomGammaDistribution = std::gamma_distribution<double>( alpha, beta );
652 return true;
653}
654
655long QgsRandomGammaRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
656{
657 return static_cast<long>( mRandomGammaDistribution( mersenneTwister ) );
658}
659
660double QgsRandomGammaRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
661{
662 return mRandomGammaDistribution( mersenneTwister );
663}
664
665//
666// QgsRandomGeometricRasterAlgorithm
667//
668QString QgsRandomGeometricRasterAlgorithm::name() const
669{
670 return QStringLiteral( "createrandomgeometricrasterlayer" );
671}
672
673QString QgsRandomGeometricRasterAlgorithm::displayName() const
674{
675 return QObject::tr( "Create random raster layer (geometric distribution)" );
676}
677
678QStringList QgsRandomGeometricRasterAlgorithm::tags() const
679{
680 return QObject::tr( "raster,create,random,geometric" ).split( ',' );
681}
682
683QString QgsRandomGeometricRasterAlgorithm::shortHelpString() const
684{
685 return QObject::tr( "Generates a raster layer for given extent and cell size "
686 "filled with geometrically distributed random values.\n"
687 "By default, the values will be chosen given a probability of 0.5. "
688 "This can be overridden by using the advanced parameter for mean "
689 "value. The raster data type is set to Integer types (Integer16 by default). "
690 "The geometric distribution random values are defined as positive integer numbers. "
691 "A floating point raster will represent a cast of "
692 "integer values to floating point." );
693}
694
695QgsRandomGeometricRasterAlgorithm *QgsRandomGeometricRasterAlgorithm::createInstance() const
696{
697 return new QgsRandomGeometricRasterAlgorithm();
698}
699
700
701void QgsRandomGeometricRasterAlgorithm::addAlgorithmParams()
702{
703 QStringList rasterDataTypes = QStringList();
704 rasterDataTypes << QStringLiteral( "Integer16" )
705 << QStringLiteral( "Unsigned Integer16" )
706 << QStringLiteral( "Integer32" )
707 << QStringLiteral( "Unsigned Integer32" )
708 << QStringLiteral( "Float32" )
709 << QStringLiteral( "Float64" );
710
711 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
712 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
713 addParameter( rasterTypeParameter.release() );
714
715 std::unique_ptr<QgsProcessingParameterNumber> probabilityParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "PROBABILITY" ), QStringLiteral( "Probability" ), Qgis::ProcessingNumberParameterType::Double, 0.5, true, 0.00001 );
716 probabilityParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
717 addParameter( probabilityParameter.release() );
718}
719
720Qgis::DataType QgsRandomGeometricRasterAlgorithm::getRasterDataType( int typeId )
721{
722 switch ( typeId )
723 {
724 case 0:
726 case 1:
728 case 2:
730 case 3:
732 case 4:
734 case 5:
736 default:
738 }
739}
740
741bool QgsRandomGeometricRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
742{
743 const double probability = parameterAsDouble( parameters, QStringLiteral( "PROBABILITY" ), context );
744 mRandomGeometricDistribution = std::geometric_distribution<long>( probability );
745 return true;
746}
747
748long QgsRandomGeometricRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
749{
750 return mRandomGeometricDistribution( mersenneTwister );
751}
752
753double QgsRandomGeometricRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
754{
755 return static_cast<double>( mRandomGeometricDistribution( mersenneTwister ) );
756}
757
758//
759// QgsRandomNegativeBinomialRasterAlgorithm
760//
761QString QgsRandomNegativeBinomialRasterAlgorithm::name() const
762{
763 return QStringLiteral( "createrandomnegativebinomialrasterlayer" );
764}
765
766QString QgsRandomNegativeBinomialRasterAlgorithm::displayName() const
767{
768 return QObject::tr( "Create random raster layer (negative binomial distribution)" );
769}
770
771QStringList QgsRandomNegativeBinomialRasterAlgorithm::tags() const
772{
773 return QObject::tr( "raster,create,random,negative,binomial,negative-binomial" ).split( ',' );
774}
775
776QString QgsRandomNegativeBinomialRasterAlgorithm::shortHelpString() const
777{
778 return QObject::tr( "Generates a raster layer for given extent and cell size "
779 "filled with negative binomially distributed random values.\n"
780 "By default, the values will be chosen given a distribution parameter k of 10.0 "
781 "and a probability of 0.5. "
782 "This can be overridden by using the advanced parameters for k and probability. "
783 "The raster data type is set to Integer types (Integer 16 by default). "
784 "The negative binomial distribution random values are defined as positive integer numbers. "
785 "A floating point raster will represent a cast of "
786 "integer values to floating point." );
787}
788
789QgsRandomNegativeBinomialRasterAlgorithm *QgsRandomNegativeBinomialRasterAlgorithm::createInstance() const
790{
791 return new QgsRandomNegativeBinomialRasterAlgorithm();
792}
793
794
795void QgsRandomNegativeBinomialRasterAlgorithm::addAlgorithmParams()
796{
797 QStringList rasterDataTypes = QStringList();
798 rasterDataTypes << QStringLiteral( "Integer16" )
799 << QStringLiteral( "Unsigned Integer16" )
800 << QStringLiteral( "Integer32" )
801 << QStringLiteral( "Unsigned Integer32" )
802 << QStringLiteral( "Float32" )
803 << QStringLiteral( "Float64" );
804
805 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
806 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
807 addParameter( rasterTypeParameter.release() );
808
809 std::unique_ptr<QgsProcessingParameterNumber> kParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "K_PARAMETER" ), QStringLiteral( "Distribution parameter k" ), Qgis::ProcessingNumberParameterType::Integer, 10, true, 0.00001 );
810 kParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
811 addParameter( kParameter.release() );
812
813 std::unique_ptr<QgsProcessingParameterNumber> probabilityParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "PROBABILITY" ), QStringLiteral( "Probability" ), Qgis::ProcessingNumberParameterType::Double, 0.5, true, 0.00001 );
814 probabilityParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
815 addParameter( probabilityParameter.release() );
816}
817
818Qgis::DataType QgsRandomNegativeBinomialRasterAlgorithm::getRasterDataType( int typeId )
819{
820 switch ( typeId )
821 {
822 case 0:
824 case 1:
826 case 2:
828 case 3:
830 case 4:
832 case 5:
834 default:
836 }
837}
838
839bool QgsRandomNegativeBinomialRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
840{
841 const int k = parameterAsInt( parameters, QStringLiteral( "K_PARAMETER" ), context );
842 const double probability = parameterAsDouble( parameters, QStringLiteral( "PROBABILITY" ), context );
843 mRandomNegativeBinomialDistribution = std::negative_binomial_distribution<long>( k, probability );
844 return true;
845}
846
847long QgsRandomNegativeBinomialRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
848{
849 return mRandomNegativeBinomialDistribution( mersenneTwister );
850}
851
852double QgsRandomNegativeBinomialRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
853{
854 return static_cast<double>( mRandomNegativeBinomialDistribution( mersenneTwister ) );
855}
856
857//
858// QgsRandomNormalRasterAlgorithm
859//
860QString QgsRandomNormalRasterAlgorithm::name() const
861{
862 return QStringLiteral( "createrandomnormalrasterlayer" );
863}
864
865QString QgsRandomNormalRasterAlgorithm::displayName() const
866{
867 return QObject::tr( "Create random raster layer (normal distribution)" );
868}
869
870QStringList QgsRandomNormalRasterAlgorithm::tags() const
871{
872 return QObject::tr( "raster,create,normal,distribution,random" ).split( ',' );
873}
874
875QString QgsRandomNormalRasterAlgorithm::shortHelpString() const
876{
877 return QObject::tr( "Generates a raster layer for given extent and cell size "
878 "filled with normally distributed random values.\n"
879 "By default, the values will be chosen given a mean of 0.0 and "
880 "a standard deviation of 1.0. This can be overridden by "
881 "using the advanced parameters for mean and standard deviation "
882 "value. The raster data type is set to Float32 by default "
883 "as the normal distribution random values are floating point numbers." );
884}
885
886QgsRandomNormalRasterAlgorithm *QgsRandomNormalRasterAlgorithm::createInstance() const
887{
888 return new QgsRandomNormalRasterAlgorithm();
889}
890
891void QgsRandomNormalRasterAlgorithm::addAlgorithmParams()
892{
893 QStringList rasterDataTypes = QStringList();
894 rasterDataTypes << QStringLiteral( "Float32" )
895 << QStringLiteral( "Float64" );
896
897 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
898 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
899 addParameter( rasterTypeParameter.release() );
900
901 std::unique_ptr<QgsProcessingParameterNumber> meanParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "MEAN" ), QStringLiteral( "Mean of normal distribution" ), Qgis::ProcessingNumberParameterType::Double, 0, true );
902 meanParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
903 addParameter( meanParameter.release() );
904
905 std::unique_ptr<QgsProcessingParameterNumber> stdevParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "STDDEV" ), QStringLiteral( "Standard deviation of normal distribution" ), Qgis::ProcessingNumberParameterType::Double, 1, true, 0 );
906 stdevParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
907 addParameter( stdevParameter.release() );
908}
909
910Qgis::DataType QgsRandomNormalRasterAlgorithm::getRasterDataType( int typeId )
911{
912 switch ( typeId )
913 {
914 case 0:
916 case 1:
918 default:
920 }
921}
922
923bool QgsRandomNormalRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
924{
925 const double mean = parameterAsDouble( parameters, QStringLiteral( "MEAN" ), context );
926 const double stddev = parameterAsDouble( parameters, QStringLiteral( "STDDEV" ), context );
927 mRandomNormalDistribution = std::normal_distribution<double>( mean, stddev );
928 return true;
929}
930
931long QgsRandomNormalRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
932{
933 return static_cast<long>( mRandomNormalDistribution( mersenneTwister ) );
934}
935
936double QgsRandomNormalRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
937{
938 return mRandomNormalDistribution( mersenneTwister );
939}
940
941//
942// QgsRandomPoissonRasterAlgorithm
943//
944QString QgsRandomPoissonRasterAlgorithm::name() const
945{
946 return QStringLiteral( "createrandompoissonrasterlayer" );
947}
948
949QString QgsRandomPoissonRasterAlgorithm::displayName() const
950{
951 return QObject::tr( "Create random raster layer (poisson distribution)" );
952}
953
954QStringList QgsRandomPoissonRasterAlgorithm::tags() const
955{
956 return QObject::tr( "raster,create,random,poisson" ).split( ',' );
957}
958
959QString QgsRandomPoissonRasterAlgorithm::shortHelpString() const
960{
961 return QObject::tr( "Generates a raster layer for given extent and cell size "
962 "filled with poisson distributed random values.\n"
963 "By default, the values will be chosen given a mean of 1.0. "
964 "This can be overridden by using the advanced parameter for mean "
965 "value. The raster data type is set to Integer types (Integer16 by default). "
966 "The poisson distribution random values are positive integer numbers. "
967 "A floating point raster will represent a cast of integer values to floating point." );
968}
969
970QgsRandomPoissonRasterAlgorithm *QgsRandomPoissonRasterAlgorithm::createInstance() const
971{
972 return new QgsRandomPoissonRasterAlgorithm();
973}
974
975
976void QgsRandomPoissonRasterAlgorithm::addAlgorithmParams()
977{
978 QStringList rasterDataTypes = QStringList();
979 rasterDataTypes << QStringLiteral( "Integer16" )
980 << QStringLiteral( "Unsigned Integer16" )
981 << QStringLiteral( "Integer32" )
982 << QStringLiteral( "Unsigned Integer32" )
983 << QStringLiteral( "Float32" )
984 << QStringLiteral( "Float64" );
985
986 std::unique_ptr<QgsProcessingParameterDefinition> rasterTypeParameter = std::make_unique<QgsProcessingParameterEnum>( QStringLiteral( "OUTPUT_TYPE" ), QObject::tr( "Output raster data type" ), rasterDataTypes, false, 0, false );
987 rasterTypeParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
988 addParameter( rasterTypeParameter.release() );
989
990 std::unique_ptr<QgsProcessingParameterNumber> upperBoundParameter = std::make_unique<QgsProcessingParameterNumber>( QStringLiteral( "MEAN" ), QStringLiteral( "Mean" ), Qgis::ProcessingNumberParameterType::Double, 1.0, true, 0 );
991 upperBoundParameter->setFlags( Qgis::ProcessingParameterFlag::Advanced );
992 addParameter( upperBoundParameter.release() );
993}
994
995Qgis::DataType QgsRandomPoissonRasterAlgorithm::getRasterDataType( int typeId )
996{
997 switch ( typeId )
998 {
999 case 0:
1000 return Qgis::DataType::Int16;
1001 case 1:
1003 case 2:
1004 return Qgis::DataType::Int32;
1005 case 3:
1007 case 4:
1009 case 5:
1011 default:
1013 }
1014}
1015
1016bool QgsRandomPoissonRasterAlgorithm::prepareRandomParameters( const QVariantMap &parameters, QgsProcessingContext &context )
1017{
1018 const double mean = parameterAsDouble( parameters, QStringLiteral( "MEAN" ), context );
1019 mRandomPoissonDistribution = std::poisson_distribution<long>( mean );
1020 return true;
1021}
1022
1023long QgsRandomPoissonRasterAlgorithm::generateRandomLongValue( std::mt19937 &mersenneTwister )
1024{
1025 return mRandomPoissonDistribution( mersenneTwister );
1026}
1027
1028double QgsRandomPoissonRasterAlgorithm::generateRandomDoubleValue( std::mt19937 &mersenneTwister )
1029{
1030 return static_cast<double>( mRandomPoissonDistribution( mersenneTwister ) );
1031}
1032
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)
@ 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:6066