16#ifndef QGSRASTERANALYSISUTILS_H
17#define QGSRASTERANALYSISUTILS_H
24#include "qgis_analysis.h"
40namespace QgsRasterAnalysisUtils
47 const QgsRectangle &rasterBBox,
const QgsRectangle &featureBBox,
double cellSizeX,
double cellSizeY,
int &nCellsX,
int &nCellsY,
int rasterWidth,
int rasterHeight,
QgsRectangle &rasterBlockExtent
51 void statisticsFromMiddlePointTest(
60 const std::function<
void(
double,
const QgsPointXY & )> &addValue,
61 bool skipNodata =
true
65 void statisticsFromPreciseIntersection(
74 const std::function<
void(
double,
double,
const QgsPointXY & )> &addValue,
75 bool skipNodata =
true
79 bool validPixel(
double value );
82 void mapToPixel(
const double x,
const double y,
const QgsRectangle bounds,
const double unitsPerPixelX,
const double unitsPerPixelY,
int &px,
int &py );
85 void pixelToMap(
const int px,
const int py,
const QgsRectangle bounds,
const double unitsPerPixelX,
const double unitsPerPixelY,
double &x,
double &y );
99 struct RasterLogicInput
101 std::unique_ptr<QgsRasterInterface> sourceDataProvider;
102 std::unique_ptr<QgsRasterProjector> projector;
104 bool hasNoDataValue =
false;
105 std::vector<int> bands { 1 };
108 ANALYSIS_EXPORT
void applyRasterLogicOperator(
109 const std::vector<QgsRasterAnalysisUtils::RasterLogicInput> &inputs,
110 std::unique_ptr<QgsRasterDataProvider> destinationRaster,
111 double outputNoDataValue,
112 const bool treatNoDataAsFalse,
115 const QgsRectangle &extent,
116 QgsFeedback *feedback,
117 std::function<
void(
const std::vector<std::unique_ptr<QgsRasterBlock>> &,
bool &,
bool &,
int,
int,
bool )> &applyLogicFunc,
126 std::vector<double> getCellValuesFromBlockStack(
const std::vector<std::unique_ptr<QgsRasterBlock>> &inputBlocks,
int &row,
int &col,
bool &noDataInStack );
131 enum CellValueStatisticMethods
150 double meanFromCellValues( std::vector<double> &cellValues,
int stackSize );
155 double medianFromCellValues( std::vector<double> &cellValues,
int stackSize );
160 double stddevFromCellValues( std::vector<double> &cellValues,
int stackSize );
165 double varianceFromCellValues( std::vector<double> &cellValues,
int stackSize );
170 double maximumFromCellValues( std::vector<double> &cellValues );
175 double minimumFromCellValues( std::vector<double> &cellValues );
180 double majorityFromCellValues( std::vector<double> &cellValues,
const double noDataValue,
int stackSize );
185 double minorityFromCellValues( std::vector<double> &cellValues,
const double noDataValue,
int stackSize );
190 double rangeFromCellValues( std::vector<double> &cellValues );
195 double varietyFromCellValues( std::vector<double> &cellValues );
197 enum CellValuePercentileMethods
199 NearestRankPercentile,
200 InterpolatedPercentileInc,
201 InterpolatedPercentileExc
208 double nearestRankPercentile( std::vector<double> &cellValues,
int stackSize,
double percentile );
215 double interpolatedPercentileInc( std::vector<double> &cellValues,
int stackSize,
double percentile );
222 double interpolatedPercentileExc( std::vector<double> &cellValues,
int stackSize,
double percentile,
double noDataValue );
224 enum CellValuePercentRankMethods
226 InterpolatedPercentRankInc,
227 InterpolatedPercentRankExc
235 double interpolatedPercentRankInc( std::vector<double> &cellValues,
int stackSize,
double value,
double noDataValue );
242 double interpolatedPercentRankExc( std::vector<double> &cellValues,
int stackSize,
double value,
double noDataValue );
DataType
Raster data types.
@ Float32
Thirty two bit floating point (float).
Base class for feedback objects to be used for cancellation of something running in a worker thread.
A geometry is the spatial representation of a feature.
Base class for the definition of processing parameters.
Base class for raster data providers.
Base class for processing filters like renderers, reprojector, resampler etc.
Implements approximate projection support for optimised raster transformation.
A rectangle specified with double values.
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...