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