16#ifndef QGSRASTERANALYSISUTILS_H
17#define QGSRASTERANALYSISUTILS_H
19#include "qgis_analysis.h"
40namespace QgsRasterAnalysisUtils
46 void cellInfoForBBox(
const QgsRectangle &rasterBBox,
const QgsRectangle &featureBBox,
double cellSizeX,
double cellSizeY,
int &nCellsX,
int &nCellsY,
47 int rasterWidth,
int rasterHeight,
52 double cellSizeX,
double cellSizeY,
const QgsRectangle &rasterBBox,
const std::function<
void(
double,
const QgsPointXY & )> &addValue,
bool skipNodata =
true );
55 void statisticsFromPreciseIntersection(
QgsRasterInterface *rasterInterface,
int rasterBand,
const QgsGeometry &poly,
int nCellsX,
int nCellsY,
56 double cellSizeX,
double cellSizeY,
const QgsRectangle &rasterBBox,
const std::function<
void(
double,
double,
const QgsPointXY & )> &addValue,
bool skipNodata =
true );
59 bool validPixel(
double value );
62 void mapToPixel(
const double x,
const double y,
const QgsRectangle bounds,
const double unitsPerPixelX,
const double unitsPerPixelY,
int &px,
int &py );
65 void pixelToMap(
const int px,
const int py,
const QgsRectangle bounds,
const double unitsPerPixelX,
const double unitsPerPixelY,
double &x,
double &y );
71 std::unique_ptr< QgsProcessingParameterDefinition > createRasterTypeParameter(
const QString &name,
72 const QString &description,
81 struct RasterLogicInput
83 std::unique_ptr< QgsRasterInterface > sourceDataProvider;
84 std::unique_ptr< QgsRasterProjector> projector;
86 bool hasNoDataValue =
false;
87 std::vector< int > bands { 1 };
90 ANALYSIS_EXPORT
void applyRasterLogicOperator(
const std::vector< QgsRasterAnalysisUtils::RasterLogicInput > &inputs,
QgsRasterDataProvider *destinationRaster,
double outputNoDataValue,
const bool treatNoDataAsFalse,
92 std::function<
void(
const std::vector< std::unique_ptr< QgsRasterBlock > > &,
bool &,
bool &,
int,
int,
bool )> &applyLogicFunc,
98 std::vector<double> getCellValuesFromBlockStack(
const std::vector< std::unique_ptr< QgsRasterBlock > > &inputBlocks,
int &row,
int &col,
bool &noDataInStack );
103 enum CellValueStatisticMethods
122 double meanFromCellValues( std::vector<double> &cellValues,
int stackSize );
127 double medianFromCellValues( std::vector<double> &cellValues,
int stackSize );
132 double stddevFromCellValues( std::vector<double> &cellValues,
int stackSize );
137 double varianceFromCellValues( std::vector<double> &cellValues,
int stackSize );
142 double maximumFromCellValues( std::vector<double> &cellValues );
147 double minimumFromCellValues( std::vector<double> &cellValues );
152 double majorityFromCellValues( std::vector<double> &cellValues,
const double noDataValue,
int stackSize );
157 double minorityFromCellValues( std::vector<double> &cellValues,
const double noDataValue,
int stackSize );
162 double rangeFromCellValues( std::vector<double> &cellValues );
167 double varietyFromCellValues( std::vector<double> &cellValues );
169 enum CellValuePercentileMethods
171 NearestRankPercentile,
172 InterpolatedPercentileInc,
173 InterpolatedPercentileExc
180 double nearestRankPercentile( std::vector<double> &cellValues,
int stackSize,
double percentile );
187 double interpolatedPercentileInc( std::vector<double> &cellValues,
int stackSize,
double percentile );
194 double interpolatedPercentileExc( std::vector<double> &cellValues,
int stackSize,
double percentile,
double noDataValue );
196 enum CellValuePercentRankMethods
198 InterpolatedPercentRankInc,
199 InterpolatedPercentRankExc
207 double interpolatedPercentRankInc( std::vector<double> &cellValues,
int stackSize,
double value,
double noDataValue );
214 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.
A class to represent a 2D point.
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...