16 #ifndef QGSRASTERANALYSISUTILS_H
17 #define QGSRASTERANALYSISUTILS_H
19 #include "qgis_analysis.h"
39 namespace QgsRasterAnalysisUtils
45 void cellInfoForBBox(
const QgsRectangle &rasterBBox,
const QgsRectangle &featureBBox,
double cellSizeX,
double cellSizeY,
int &nCellsX,
int &nCellsY,
46 int rasterWidth,
int rasterHeight,
51 double cellSizeX,
double cellSizeY,
const QgsRectangle &rasterBBox,
const std::function<
void(
double )> &addValue,
bool skipNodata =
true );
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 );
58 bool validPixel(
double value );
61 void mapToPixel(
const double x,
const double y,
const QgsRectangle bounds,
const double unitsPerPixelX,
const double unitsPerPixelY,
int &px,
int &py );
64 void pixelToMap(
const int px,
const int py,
const QgsRectangle bounds,
const double unitsPerPixelX,
const double unitsPerPixelY,
double &x,
double &y );
70 std::unique_ptr< QgsProcessingParameterDefinition > createRasterTypeParameter(
const QString &name,
71 const QString &description,
80 struct RasterLogicInput
82 std::unique_ptr< QgsRasterInterface > sourceDataProvider;
83 std::unique_ptr< QgsRasterProjector> projector;
85 bool hasNoDataValue =
false;
86 std::vector< int > bands { 1 };
89 ANALYSIS_EXPORT
void applyRasterLogicOperator(
const std::vector< QgsRasterAnalysisUtils::RasterLogicInput > &inputs,
QgsRasterDataProvider *destinationRaster,
double outputNoDataValue,
const bool treatNoDataAsFalse,
91 std::function<
void(
const std::vector< std::unique_ptr< QgsRasterBlock > > &,
bool &,
bool &,
int,
int,
bool )> &applyLogicFunc,
97 std::vector<double> getCellValuesFromBlockStack(
const std::vector< std::unique_ptr< QgsRasterBlock > > &inputBlocks,
int &row,
int &col,
bool &noDataInStack );
102 enum CellValueStatisticMethods
121 double meanFromCellValues( std::vector<double> cellValues,
int stackSize );
126 double medianFromCellValues( std::vector<double> cellValues,
int stackSize );
131 double stddevFromCellValues( std::vector<double> cellValues,
int stackSize );
136 double varianceFromCellValues( std::vector<double> cellValues,
int stackSize );
141 double maximumFromCellValues( std::vector<double> cellValues );
146 double minimumFromCellValues( std::vector<double> cellValues );
151 double majorityFromCellValues( std::vector<double> cellValues,
const double noDataValue,
int stackSize );
156 double minorityFromCellValues( std::vector<double> cellValues,
const double noDataValue,
int stackSize );
161 double rangeFromCellValues( std::vector<double> cellValues );
166 double varietyFromCellValues( std::vector<double> cellValues );
173 #endif // QGSRASTERANALYSISUTILS_H