QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsrasteranalysisutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasteranalysisutils.h
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 
16 #ifndef QGSRASTERANALYSISUTILS_H
17 #define QGSRASTERANALYSISUTILS_H
18 
19 #include "qgis_analysis.h"
20 #include "qgis.h"
21 
22 #include <functional>
23 #include <memory>
24 #include <vector>
25 
26 #define SIP_NO_FILE
27 
29 
30 class QgsRasterInterface;
31 class QgsGeometry;
32 class QgsRectangle;
34 class QgsRasterProjector;
36 class QgsFeedback;
37 class QgsRasterBlock;
38 
39 namespace QgsRasterAnalysisUtils
40 {
41 
45  void cellInfoForBBox( const QgsRectangle &rasterBBox, const QgsRectangle &featureBBox, double cellSizeX, double cellSizeY, int &nCellsX, int &nCellsY,
46  int rasterWidth, int rasterHeight,
47  QgsRectangle &rasterBlockExtent );
48 
50  void statisticsFromMiddlePointTest( QgsRasterInterface *rasterInterface, int rasterBand, const QgsGeometry &poly, int nCellsX, int nCellsY,
51  double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, const std::function<void( double )> &addValue, bool skipNodata = true );
52 
54  void statisticsFromPreciseIntersection( QgsRasterInterface *rasterInterface, int rasterBand, const QgsGeometry &poly, int nCellsX, int nCellsY,
55  double cellSizeX, double cellSizeY, const QgsRectangle &rasterBBox, const std::function<void( double, double )> &addValue, bool skipNodata = true );
56 
58  bool validPixel( double value );
59 
64  std::unique_ptr< QgsProcessingParameterDefinition > createRasterTypeParameter( const QString &name,
65  const QString &description,
66  Qgis::DataType defaultType = Qgis::Float32 );
67 
72  Qgis::DataType rasterTypeChoiceToDataType( int choice );
73 
74  struct RasterLogicInput
75  {
76  std::unique_ptr< QgsRasterInterface > sourceDataProvider;
77  std::unique_ptr< QgsRasterProjector> projector;
78  QgsRasterInterface *interface = nullptr;
79  bool hasNoDataValue = false;
80  std::vector< int > bands { 1 };
81  };
82 
83  ANALYSIS_EXPORT void applyRasterLogicOperator( const std::vector< QgsRasterAnalysisUtils::RasterLogicInput > &inputs, QgsRasterDataProvider *destinationRaster, double outputNoDataValue, const bool treatNoDataAsFalse,
84  int width, int height, const QgsRectangle &extent, QgsFeedback *feedback,
85  std::function<void( const std::vector< std::unique_ptr< QgsRasterBlock > > &, bool &, bool &, int, int, bool )> &applyLogicFunc,
86  qgssize &noDataCount, qgssize &trueCount, qgssize &falseCount );
87 
88 }
89 
90 
92 
93 #endif // QGSRASTERANALYSISUTILS_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
DataType
Raster data types.
Definition: qgis.h:79
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:111
Thirty two bit floating point (float)
Definition: qgis.h:87
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:44
Raster data container.
Base class for processing filters like renderers, reprojector, resampler etc.
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:596
QgsRasterProjector implements approximate projection support for it calculates grid of points in sour...
Base class for the definition of processing parameters.
Base class for raster data providers.