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