QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsrasteranalysisutils.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasteranalysisutils.cpp
3 ---------------------
4 Date : June 2018
5 Copyright : (C) 2018 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include <cmath>
19#include <map>
20#include <unordered_map>
21#include <unordered_set>
22
23#include "qgsfeedback.h"
24#include "qgsgeos.h"
26#include "qgsrasterblock.h"
27#include "qgsrasteriterator.h"
28
30
31void QgsRasterAnalysisUtils::cellInfoForBBox( const QgsRectangle &rasterBBox, const QgsRectangle &featureBBox, double cellSizeX, double cellSizeY, int &nCellsX, int &nCellsY, int rasterWidth, int rasterHeight, QgsRectangle &rasterBlockExtent )
32{
33 //get intersecting bbox
34 const QgsRectangle intersectBox = rasterBBox.intersect( featureBBox );
35 if ( intersectBox.isEmpty() )
36 {
37 nCellsX = 0;
38 nCellsY = 0;
39 rasterBlockExtent = QgsRectangle();
40 return;
41 }
42
43 //get offset in pixels in x- and y- direction
44 const int offsetX = static_cast<int>( std::floor( ( intersectBox.xMinimum() - rasterBBox.xMinimum() ) / cellSizeX ) );
45 const int offsetY = static_cast<int>( std::floor( ( rasterBBox.yMaximum() - intersectBox.yMaximum() ) / cellSizeY ) );
46
47 const int maxColumn = static_cast<int>( std::floor( ( intersectBox.xMaximum() - rasterBBox.xMinimum() ) / cellSizeX ) ) + 1;
48 const int maxRow = static_cast<int>( std::floor( ( rasterBBox.yMaximum() - intersectBox.yMinimum() ) / cellSizeY ) ) + 1;
49
50 nCellsX = maxColumn - offsetX;
51 nCellsY = maxRow - offsetY;
52
53 //avoid access to cells outside of the raster (may occur because of rounding)
54 nCellsX = std::min( offsetX + nCellsX, rasterWidth ) - offsetX;
55 nCellsY = std::min( offsetY + nCellsY, rasterHeight ) - offsetY;
56
57 rasterBlockExtent = QgsRectangle( rasterBBox.xMinimum() + offsetX * cellSizeX, rasterBBox.yMaximum() - offsetY * cellSizeY, rasterBBox.xMinimum() + ( nCellsX + offsetX ) * cellSizeX, rasterBBox.yMaximum() - ( nCellsY + offsetY ) * cellSizeY );
58}
59
60void QgsRasterAnalysisUtils::statisticsFromMiddlePointTest( QgsRasterInterface *rasterInterface, int rasterBand, const QgsGeometry &poly, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, const std::function<void( double, const QgsPointXY & )> &addValue, bool skipNodata )
61{
62 if ( !poly.constGet() )
63 return;
64
65 auto polyEngine = std::make_unique<QgsGeos>( poly.constGet() );
66 polyEngine->prepareGeometry();
67
68 QgsRasterIterator iter( rasterInterface );
69 iter.startRasterRead( rasterBand, nCellsX, nCellsY, rasterBBox );
70
71 std::unique_ptr<QgsRasterBlock> block;
72 int iterLeft = 0;
73 int iterTop = 0;
74 int iterCols = 0;
75 int iterRows = 0;
76 QgsRectangle blockExtent;
77 bool isNoData = false;
78 while ( iter.readNextRasterPart( rasterBand, iterCols, iterRows, block, iterLeft, iterTop, &blockExtent ) )
79 {
80 double cellCenterY = blockExtent.yMaximum() - 0.5 * cellSizeY;
81
82 for ( int row = 0; row < iterRows; ++row )
83 {
84 double cellCenterX = blockExtent.xMinimum() + 0.5 * cellSizeX;
85 for ( int col = 0; col < iterCols; ++col )
86 {
87 const double pixelValue = block->valueAndNoData( row, col, isNoData );
88 if ( validPixel( pixelValue ) && ( !skipNodata || !isNoData ) )
89 {
90 if ( polyEngine->contains( cellCenterX, cellCenterY ) )
91 {
92 addValue( pixelValue, QgsPointXY( cellCenterX, cellCenterY ) );
93 }
94 }
95 cellCenterX += cellSizeX;
96 }
97 cellCenterY -= cellSizeY;
98 }
99 }
100}
101
102void QgsRasterAnalysisUtils::statisticsFromPreciseIntersection( QgsRasterInterface *rasterInterface, int rasterBand, const QgsGeometry &poly, int nCellsX, int nCellsY, double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, const std::function<void( double, double, const QgsPointXY & )> &addValue, bool skipNodata )
103{
104 QgsGeometry pixelRectGeometry;
105
106 const double hCellSizeX = cellSizeX / 2.0;
107 const double hCellSizeY = cellSizeY / 2.0;
108 const double pixelArea = cellSizeX * cellSizeY;
109 double weight = 0;
110
111 std::unique_ptr<QgsGeometryEngine> polyEngine( QgsGeometry::createGeometryEngine( poly.constGet() ) );
112 if ( !polyEngine )
113 {
114 return;
115 }
116 polyEngine->prepareGeometry();
117
118 QgsRasterIterator iter( rasterInterface );
119 iter.startRasterRead( rasterBand, nCellsX, nCellsY, rasterBBox );
120
121 std::unique_ptr<QgsRasterBlock> block;
122 int iterLeft = 0;
123 int iterTop = 0;
124 int iterCols = 0;
125 int iterRows = 0;
126 QgsRectangle blockExtent;
127 bool isNoData = false;
128 while ( iter.readNextRasterPart( rasterBand, iterCols, iterRows, block, iterLeft, iterTop, &blockExtent ) )
129 {
130 double currentY = blockExtent.yMaximum() - 0.5 * cellSizeY;
131 for ( int row = 0; row < iterRows; ++row )
132 {
133 double currentX = blockExtent.xMinimum() + 0.5 * cellSizeX;
134 for ( int col = 0; col < iterCols; ++col )
135 {
136 const double pixelValue = block->valueAndNoData( row, col, isNoData );
137 if ( validPixel( pixelValue ) && ( !skipNodata || !isNoData ) )
138 {
139 pixelRectGeometry = QgsGeometry::fromRect( QgsRectangle( currentX - hCellSizeX, currentY - hCellSizeY, currentX + hCellSizeX, currentY + hCellSizeY ) );
140 // GEOS intersects tests on prepared geometry is MAGNITUDES faster than calculating the intersection itself,
141 // so we first test to see if there IS an intersection before doing the actual calculation
142 if ( !pixelRectGeometry.isNull() && polyEngine->intersects( pixelRectGeometry.constGet() ) )
143 {
144 //intersection
145 const QgsGeometry intersectGeometry = pixelRectGeometry.intersection( poly );
146 if ( !intersectGeometry.isEmpty() )
147 {
148 const double intersectionArea = intersectGeometry.area();
149 if ( intersectionArea > 0.0 )
150 {
151 weight = intersectionArea / pixelArea;
152 addValue( pixelValue, weight, QgsPointXY( currentX, currentY ) );
153 }
154 }
155 }
156 }
157 currentX += cellSizeX;
158 }
159 currentY -= cellSizeY;
160 }
161 }
162}
163
164bool QgsRasterAnalysisUtils::validPixel( double value )
165{
166 return !std::isnan( value );
167}
168
169void QgsRasterAnalysisUtils::mapToPixel( const double x, const double y, const QgsRectangle bounds, const double unitsPerPixelX, const double unitsPerPixelY, int &px, int &py )
170{
171 px = trunc( ( x - bounds.xMinimum() ) / unitsPerPixelX );
172 py = trunc( ( y - bounds.yMaximum() ) / -unitsPerPixelY );
173}
174
175void QgsRasterAnalysisUtils::pixelToMap( const int px, const int py, const QgsRectangle bounds, const double unitsPerPixelX, const double unitsPerPixelY, double &x, double &y )
176{
177 x = bounds.xMinimum() + ( px + 0.5 ) * unitsPerPixelX;
178 y = bounds.yMaximum() - ( py + 0.5 ) * unitsPerPixelY;
179}
180
181static QVector<QPair<QString, Qgis::DataType>> sDataTypes;
182
183void populateDataTypes()
184{
185 if ( sDataTypes.empty() )
186 {
187 sDataTypes.append( qMakePair( QStringLiteral( "Byte" ), Qgis::DataType::Byte ) );
188 sDataTypes.append( qMakePair( QStringLiteral( "Int16" ), Qgis::DataType::Int16 ) );
189 sDataTypes.append( qMakePair( QStringLiteral( "UInt16" ), Qgis::DataType::UInt16 ) );
190 sDataTypes.append( qMakePair( QStringLiteral( "Int32" ), Qgis::DataType::Int32 ) );
191 sDataTypes.append( qMakePair( QStringLiteral( "UInt32" ), Qgis::DataType::UInt32 ) );
192 sDataTypes.append( qMakePair( QStringLiteral( "Float32" ), Qgis::DataType::Float32 ) );
193 sDataTypes.append( qMakePair( QStringLiteral( "Float64" ), Qgis::DataType::Float64 ) );
194 sDataTypes.append( qMakePair( QStringLiteral( "CInt16" ), Qgis::DataType::CInt16 ) );
195 sDataTypes.append( qMakePair( QStringLiteral( "CInt32" ), Qgis::DataType::CInt32 ) );
196 sDataTypes.append( qMakePair( QStringLiteral( "CFloat32" ), Qgis::DataType::CFloat32 ) );
197 sDataTypes.append( qMakePair( QStringLiteral( "CFloat64" ), Qgis::DataType::CFloat64 ) );
198 sDataTypes.append( qMakePair( QStringLiteral( "Int8" ), Qgis::DataType::Int8 ) );
199 }
200}
201
202std::unique_ptr<QgsProcessingParameterDefinition> QgsRasterAnalysisUtils::createRasterTypeParameter( const QString &name, const QString &description, Qgis::DataType defaultType )
203{
204 populateDataTypes();
205
206 QStringList names;
207 int defaultChoice = 0;
208 int i = 0;
209 for ( auto it = sDataTypes.constBegin(); it != sDataTypes.constEnd(); ++it )
210 {
211 names.append( it->first );
212 if ( it->second == defaultType )
213 defaultChoice = i;
214 i++;
215 }
216
217 return std::make_unique<QgsProcessingParameterEnum>( name, description, names, false, defaultChoice );
218}
219
220Qgis::DataType QgsRasterAnalysisUtils::rasterTypeChoiceToDataType( int choice )
221{
222 if ( choice < 0 || choice >= sDataTypes.count() )
224
225 return sDataTypes.value( choice ).second;
226}
227
228void QgsRasterAnalysisUtils::applyRasterLogicOperator( const std::vector<QgsRasterAnalysisUtils::RasterLogicInput> &inputs, QgsRasterDataProvider *destinationRaster, double outputNoDataValue, const bool treatNoDataAsFalse, int width, int height, const QgsRectangle &extent, QgsFeedback *feedback, std::function<void( const std::vector<std::unique_ptr<QgsRasterBlock>> &, bool &, bool &, int, int, bool )> &applyLogicFunc, qgssize &noDataCount, qgssize &trueCount, qgssize &falseCount )
229{
232 const int nbBlocksWidth = static_cast<int>( std::ceil( 1.0 * width / maxWidth ) );
233 const int nbBlocksHeight = static_cast<int>( std::ceil( 1.0 * height / maxHeight ) );
234 const int nbBlocks = nbBlocksWidth * nbBlocksHeight;
235
236 destinationRaster->setEditable( true );
237 QgsRasterIterator outputIter( destinationRaster );
238 outputIter.startRasterRead( 1, width, height, extent );
239
240 int iterLeft = 0;
241 int iterTop = 0;
242 int iterCols = 0;
243 int iterRows = 0;
244 QgsRectangle blockExtent;
245 std::unique_ptr<QgsRasterBlock> outputBlock;
246 while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
247 {
248 std::vector<std::unique_ptr<QgsRasterBlock>> inputBlocks;
249 for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : inputs )
250 {
251 for ( const int band : i.bands )
252 {
253 std::unique_ptr<QgsRasterBlock> b( i.interface->block( band, blockExtent, iterCols, iterRows ) );
254 inputBlocks.emplace_back( std::move( b ) );
255 }
256 }
257
258 feedback->setProgress( 100 * ( ( iterTop / maxHeight * nbBlocksWidth ) + iterLeft / maxWidth ) / nbBlocks );
259 for ( int row = 0; row < iterRows; row++ )
260 {
261 if ( feedback->isCanceled() )
262 break;
263
264 for ( int column = 0; column < iterCols; column++ )
265 {
266 bool res = false;
267 bool resIsNoData = false;
268 applyLogicFunc( inputBlocks, res, resIsNoData, row, column, treatNoDataAsFalse );
269 if ( resIsNoData )
270 noDataCount++;
271 else if ( res )
272 trueCount++;
273 else
274 falseCount++;
275
276 outputBlock->setValue( row, column, resIsNoData ? outputNoDataValue : ( res ? 1 : 0 ) );
277 }
278 }
279 if ( !destinationRaster->writeBlock( outputBlock.get(), 1, iterLeft, iterTop ) )
280 {
281 throw QgsProcessingException( QObject::tr( "Could not write raster block: %1" ).arg( destinationRaster->error().summary() ) );
282 }
283 }
284 destinationRaster->setEditable( false );
285}
286
287std::vector<double> QgsRasterAnalysisUtils::getCellValuesFromBlockStack( const std::vector<std::unique_ptr<QgsRasterBlock>> &inputBlocks, int &row, int &col, bool &noDataInStack )
288{
289 //get all values from inputBlocks
290 std::vector<double> cellValues;
291 bool hasNoData = false;
292 cellValues.reserve( inputBlocks.size() );
293
294 for ( auto &block : inputBlocks )
295 {
296 double value = 0;
297 if ( !block || !block->isValid() )
298 {
299 noDataInStack = true;
300 break;
301 }
302 else
303 {
304 value = block->valueAndNoData( row, col, hasNoData );
305 if ( hasNoData )
306 {
307 noDataInStack = true;
308 continue; //NoData is not included in the cell value vector
309 }
310 else
311 {
312 cellValues.push_back( value );
313 }
314 }
315 }
316 return cellValues;
317}
318
319double QgsRasterAnalysisUtils::meanFromCellValues( std::vector<double> &cellValues, int stackSize )
320{
321 const double sum = std::accumulate( cellValues.begin(), cellValues.end(), 0.0 );
322 const double mean = sum / static_cast<double>( stackSize );
323 return mean;
324}
325
326double QgsRasterAnalysisUtils::medianFromCellValues( std::vector<double> &cellValues, int stackSize )
327{
328 std::sort( cellValues.begin(), cellValues.end() );
329 const bool even = ( stackSize % 2 ) < 1;
330 if ( even )
331 {
332 return ( cellValues[stackSize / 2 - 1] + cellValues[stackSize / 2] ) / 2.0;
333 }
334 else //odd
335 {
336 return cellValues[( stackSize + 1 ) / 2 - 1];
337 }
338}
339
340
341double QgsRasterAnalysisUtils::stddevFromCellValues( std::vector<double> &cellValues, int stackSize )
342{
343 const double variance = varianceFromCellValues( cellValues, stackSize );
344 const double stddev = std::sqrt( variance );
345 return stddev;
346}
347
348double QgsRasterAnalysisUtils::varianceFromCellValues( std::vector<double> &cellValues, int stackSize )
349{
350 const double mean = meanFromCellValues( cellValues, stackSize );
351 double accum = 0.0;
352 for ( int i = 0; i < stackSize; i++ )
353 {
354 accum += std::pow( ( cellValues.at( i ) - mean ), 2.0 );
355 }
356 const double variance = accum / static_cast<double>( stackSize );
357 return variance;
358}
359
360double QgsRasterAnalysisUtils::maximumFromCellValues( std::vector<double> &cellValues )
361{
362 return *std::max_element( cellValues.begin(), cellValues.end() );
363}
364
365double QgsRasterAnalysisUtils::minimumFromCellValues( std::vector<double> &cellValues )
366{
367 return *std::min_element( cellValues.begin(), cellValues.end() );
368}
369
370double QgsRasterAnalysisUtils::majorityFromCellValues( std::vector<double> &cellValues, const double noDataValue, int stackSize )
371{
372 if ( stackSize == 1 )
373 {
374 //output will be same as input if only one layer is entered
375 return cellValues[0];
376 }
377 else if ( stackSize == 2 )
378 {
379 //if only two layers are input, return NoData if values are not the same (eg. no Majority could be found)
380 return ( qgsDoubleNear( cellValues[0], cellValues[1] ) ) ? cellValues[0] : noDataValue;
381 }
382 else if ( std::adjacent_find( cellValues.begin(), cellValues.end(), std::not_equal_to<double>() ) == cellValues.end() )
383 {
384 //check if all values in cellValues are equal
385 //output will be same as input if all cellValues of the stack are the same
386 return cellValues[0];
387 }
388 else
389 {
390 //search for majority using hash map [O(n)]
391 std::unordered_map<double, int> map;
392
393 for ( int i = 0; i < stackSize; i++ )
394 {
395 map[cellValues[i]]++;
396 }
397
398 int maxCount = 0;
399 bool multipleMajorities = false;
400 double result = noDataValue;
401 for ( const auto &pair : std::as_const( map ) )
402 {
403 if ( maxCount < pair.second )
404 {
405 result = pair.first;
406 maxCount = pair.second;
407 multipleMajorities = false;
408 }
409 else if ( maxCount == pair.second )
410 {
411 multipleMajorities = true;
412 }
413 }
414 return multipleMajorities ? noDataValue : result;
415 }
416}
417
418double QgsRasterAnalysisUtils::minorityFromCellValues( std::vector<double> &cellValues, const double noDataValue, int stackSize )
419{
420 if ( stackSize == 1 )
421 {
422 //output will be same as input if only one layer is entered
423 return cellValues[0];
424 }
425 else if ( stackSize == 2 )
426 {
427 //if only two layers are input, return NoData if values are not the same (eg. no minority could be found)
428 return ( qgsDoubleNear( cellValues[0], cellValues[1] ) ) ? cellValues[0] : noDataValue;
429 }
430 else if ( std::adjacent_find( cellValues.begin(), cellValues.end(), std::not_equal_to<double>() ) == cellValues.end() )
431 {
432 //check if all values in cellValues are equal
433 //output will be same as input if all cellValues of the stack are the same
434 return cellValues[0];
435 }
436 else
437 {
438 //search for minority using hash map [O(n)]
439 std::unordered_map<double, int> map;
440
441 for ( int i = 0; i < stackSize; i++ )
442 {
443 map[cellValues[i]]++;
444 }
445
446 int minCount = stackSize;
447 bool multipleMinorities = false;
448 double result = noDataValue; //result will stay NoData if no minority value exists
449 for ( const auto &pair : std::as_const( map ) )
450 {
451 if ( minCount > pair.second )
452 {
453 result = pair.first;
454 minCount = pair.second;
455 multipleMinorities = false;
456 }
457 else if ( minCount == pair.second )
458 {
459 multipleMinorities = true;
460 }
461 }
462 return multipleMinorities ? noDataValue : result;
463 }
464}
465
466double QgsRasterAnalysisUtils::rangeFromCellValues( std::vector<double> &cellValues )
467{
468 const double max = *std::max_element( cellValues.begin(), cellValues.end() );
469 const double min = *std::min_element( cellValues.begin(), cellValues.end() );
470 return max - min;
471}
472
473double QgsRasterAnalysisUtils::varietyFromCellValues( std::vector<double> &cellValues )
474{
475 const std::unordered_set<double> uniqueValues( cellValues.begin(), cellValues.end() );
476 return uniqueValues.size();
477}
478
479double QgsRasterAnalysisUtils::nearestRankPercentile( std::vector<double> &cellValues, int stackSize, double percentile )
480{
481 //if percentile equals 0 -> pick the first element of the ordered list
482 std::sort( cellValues.begin(), cellValues.end() );
483
484 int i = 0;
485 if ( percentile > 0 )
486 {
487 i = std::ceil( percentile * static_cast<double>( stackSize ) ) - 1;
488 }
489
490 return cellValues[i];
491}
492
493double QgsRasterAnalysisUtils::interpolatedPercentileInc( std::vector<double> &cellValues, int stackSize, double percentile )
494{
495 std::sort( cellValues.begin(), cellValues.end() );
496
497 if ( qgsDoubleNear( percentile, 1.0 ) )
498 {
499 return cellValues[stackSize - 1];
500 }
501 else if ( qgsDoubleNear( percentile, 0.0 ) )
502 {
503 return cellValues[0];
504 }
505
506 const double x = ( percentile * ( stackSize - 1 ) );
507
508 const int i = static_cast<int>( std::floor( x ) );
509 const double xFraction = std::fmod( x, 1 );
510
511 if ( stackSize == 1 )
512 {
513 return cellValues[0];
514 }
515 else if ( stackSize == 2 )
516 {
517 return cellValues[0] + ( cellValues[1] - cellValues[0] ) * percentile;
518 }
519 else
520 {
521 return cellValues[i] + ( cellValues[i + 1] - cellValues[i] ) * xFraction;
522 }
523}
524
525double QgsRasterAnalysisUtils::interpolatedPercentileExc( std::vector<double> &cellValues, int stackSize, double percentile, double noDataValue )
526{
527 std::sort( cellValues.begin(), cellValues.end() );
528 const double x = ( percentile * ( stackSize + 1 ) );
529
530 const int i = static_cast<int>( std::floor( x ) ) - 1;
531 const double xFraction = std::fmod( x, 1 );
532 const double lowerExcValue = 1.0 / ( static_cast<double>( stackSize ) + 1.0 );
533 const double upperExcValue = static_cast<double>( stackSize ) / ( static_cast<double>( stackSize ) + 1.0 );
534
535 if ( stackSize < 2 || ( ( percentile < lowerExcValue || percentile > upperExcValue ) ) )
536 {
537 return noDataValue;
538 }
539 else
540 {
541 return cellValues[i] + ( cellValues[i + 1] - cellValues[i] ) * xFraction;
542 }
543}
544
545double QgsRasterAnalysisUtils::interpolatedPercentRankInc( std::vector<double> &cellValues, int stackSize, double value, double noDataValue )
546{
547 std::sort( cellValues.begin(), cellValues.end() );
548
549 if ( value < cellValues[0] || value > cellValues[stackSize - 1] )
550 {
551 return noDataValue;
552 }
553 else
554 {
555 for ( int i = 0; i < stackSize - 1; i++ )
556 {
557 if ( cellValues[i] <= value && cellValues[i + 1] >= value )
558 {
559 double fraction = 0.0;
560
561 //make sure that next number in the distribution is not the same to prevent NaN fractions
562 if ( !qgsDoubleNear( cellValues[i], cellValues[i + 1] ) )
563 fraction = ( value - cellValues[i] ) / ( cellValues[i + 1] - cellValues[i] );
564
565 return ( fraction + i ) / ( stackSize - 1 );
566 }
567 }
568 return noDataValue;
569 }
570}
571
572double QgsRasterAnalysisUtils::interpolatedPercentRankExc( std::vector<double> &cellValues, int stackSize, double value, double noDataValue )
573{
574 std::sort( cellValues.begin(), cellValues.end() );
575
576 if ( value < cellValues[0] || value > cellValues[stackSize - 1] )
577 {
578 return noDataValue;
579 }
580 else
581 {
582 for ( int i = 0; i < stackSize - 1; i++ )
583 {
584 if ( cellValues[i] <= value && cellValues[i + 1] >= value )
585 {
586 double fraction = 0.0;
587
588 //make sure that next number in the distribution is not the same to prevent NaN fractions
589 if ( !qgsDoubleNear( cellValues[i], cellValues[i + 1] ) )
590 fraction = ( value - cellValues[i] ) / ( cellValues[i + 1] - cellValues[i] );
591
592 return ( ( i + 1 ) + fraction ) / ( stackSize + 1 );
593 }
594 }
595 return noDataValue;
596 }
597}
598
599
DataType
Raster data types.
Definition qgis.h:372
@ CInt32
Complex Int32.
Definition qgis.h:383
@ Float32
Thirty two bit floating point (float).
Definition qgis.h:380
@ CFloat64
Complex Float64.
Definition qgis.h:385
@ Int16
Sixteen bit signed integer (qint16).
Definition qgis.h:377
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30).
Definition qgis.h:375
@ UInt16
Sixteen bit unsigned integer (quint16).
Definition qgis.h:376
@ Byte
Eight bit unsigned integer (quint8).
Definition qgis.h:374
@ Int32
Thirty two bit signed integer (qint32).
Definition qgis.h:379
@ Float64
Sixty four bit floating point (double).
Definition qgis.h:381
@ CFloat32
Complex Float32.
Definition qgis.h:384
@ CInt16
Complex Int16.
Definition qgis.h:382
@ UInt32
Thirty two bit unsigned integer (quint32).
Definition qgis.h:378
virtual QgsError error() const
Gets current status error.
QString summary() const
Short error description, usually the first error in chain, the real error.
Definition qgserror.cpp:130
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
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
A geometry is the spatial representation of a feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
double area() const
Returns the planar, 2-dimensional area of the geometry.
QgsGeometry intersection(const QgsGeometry &geometry, const QgsGeometryParameters &parameters=QgsGeometryParameters()) const
Returns a geometry representing the points shared by this geometry and other.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
Represents a 2D point.
Definition qgspointxy.h:60
Custom exception class for processing related exceptions.
Base class for raster data providers.
bool writeBlock(QgsRasterBlock *block, int band, int xOffset=0, int yOffset=0)
Writes pixel data from a raster block into the provider data source.
virtual bool setEditable(bool enabled)
Turns on/off editing mode of the provider.
Base class for processing filters like renderers, reprojector, resampler etc.
Iterator for sequentially processing raster cells.
static const int DEFAULT_MAXIMUM_TILE_WIDTH
Default maximum tile width.
static const int DEFAULT_MAXIMUM_TILE_HEIGHT
Default maximum tile height.
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
double yMaximum
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
Definition qgis.h:7142
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:6607