QGIS API Documentation 3.43.0-Master (0bee5d6404c)
Public Types | Public Member Functions | Protected Attributes | List of all members
QgsNineCellFilter Class Referenceabstract

Base class for raster analysis methods that work with a 3x3 cell filter and calculate the value of each cell based on the cell value and the eight neighbour cells. More...

#include <qgsninecellfilter.h>

Inheritance diagram for QgsNineCellFilter:
Inheritance graph
[legend]

Public Types

enum class  Result : int {
  Success = 0 , InputLayerError = 1 , DriverError = 2 , CreateOutputError = 3 ,
  InputBandError = 4 , OutputBandError = 5 , RasterSizeError = 6 , Canceled = 7
}
 Result of the calculation. More...
 

Public Member Functions

 QgsNineCellFilter (const QString &inputFile, const QString &outputFile, const QString &outputFormat)
 Constructor that takes input file, output file and output format (GDAL string)
 
virtual ~QgsNineCellFilter ()=default
 
double cellSizeX () const
 
double cellSizeY () const
 
QStringList creationOptions () const
 Returns the list of data source creation options which will be used when creating the output raster file.
 
double inputNodataValue () const
 
double outputNodataValue () const
 
virtual float processNineCellWindow (float *x11, float *x21, float *x31, float *x12, float *x22, float *x32, float *x13, float *x23, float *x33)=0
 Calculates output value from nine input values.
 
Result processRaster (QgsFeedback *feedback=nullptr)
 Starts the calculation, reads from mInputFile and stores the result in mOutputFile.
 
void setCellSizeX (double size)
 
void setCellSizeY (double size)
 
void setCreationOptions (const QStringList &list)
 Sets a list of data source creation options to use when creating the output raster file.
 
void setInputNodataValue (double value)
 
void setOutputNodataValue (double value)
 
void setZFactor (double factor)
 
double zFactor () const
 

Protected Attributes

double mCellSizeX = -1.0
 
double mCellSizeY = -1.0
 
QStringList mCreationOptions
 
QString mInputFile
 
double mInputNodataValue = -1.0
 The nodata value of the input layer.
 
QString mOutputFile
 
QString mOutputFormat
 
double mOutputNodataValue = -9999.0
 The nodata value of the output layer.
 
double mZFactor = 1.0
 Scale factor for z-value if x-/y- units are different to z-units (111120 for degree->meters and 370400 for degree->feet)
 

Detailed Description

Base class for raster analysis methods that work with a 3x3 cell filter and calculate the value of each cell based on the cell value and the eight neighbour cells.

Common examples are slope and aspect calculation in DEMs. Subclasses only implement the method that calculates the new value from the nine values. Everything else (reading file, writing file) is done by this subclass

Definition at line 37 of file qgsninecellfilter.h.

Member Enumeration Documentation

◆ Result

enum class QgsNineCellFilter::Result : int
strong

Result of the calculation.

Since
QGIS 3.44
Enumerator
Success 

Operation completed successfully.

InputLayerError 

Error reading input file.

DriverError 

Could not open the driver for the specified format.

CreateOutputError 

Error creating output file.

InputBandError 

Error reading input raster band.

OutputBandError 

Error reading output raster band.

RasterSizeError 

Raster height is too small (need at least 3 rows)

Canceled 

User canceled calculation.

Definition at line 41 of file qgsninecellfilter.h.

Constructor & Destructor Documentation

◆ QgsNineCellFilter()

QgsNineCellFilter::QgsNineCellFilter ( const QString &  inputFile,
const QString &  outputFile,
const QString &  outputFormat 
)

Constructor that takes input file, output file and output format (GDAL string)

Definition at line 36 of file qgsninecellfilter.cpp.

◆ ~QgsNineCellFilter()

virtual QgsNineCellFilter::~QgsNineCellFilter ( )
virtualdefault

Member Function Documentation

◆ cellSizeX()

double QgsNineCellFilter::cellSizeX ( ) const
inline

Definition at line 64 of file qgsninecellfilter.h.

◆ cellSizeY()

double QgsNineCellFilter::cellSizeY ( ) const
inline

Definition at line 66 of file qgsninecellfilter.h.

◆ creationOptions()

QStringList QgsNineCellFilter::creationOptions ( ) const
inline

Returns the list of data source creation options which will be used when creating the output raster file.

See also
setCreationOptions()
Since
QGIS 3.44

Definition at line 91 of file qgsninecellfilter.h.

◆ inputNodataValue()

double QgsNineCellFilter::inputNodataValue ( ) const
inline

Definition at line 72 of file qgsninecellfilter.h.

◆ outputNodataValue()

double QgsNineCellFilter::outputNodataValue ( ) const
inline

Definition at line 74 of file qgsninecellfilter.h.

◆ processNineCellWindow()

virtual float QgsNineCellFilter::processNineCellWindow ( float *  x11,
float *  x21,
float *  x31,
float *  x12,
float *  x22,
float *  x32,
float *  x13,
float *  x23,
float *  x33 
)
pure virtual

Calculates output value from nine input values.

The input values and the output value can be equal to the nodata value if not present or outside of the border. Must be implemented by subclasses.

First index of the input cell is the row, second index is the column

Parameters
x11surrounding cell top left
x21surrounding cell central left
x31surrounding cell bottom left
x12surrounding cell top central
x22the central cell for which the value will be calculated
x32surrounding cell bottom central
x13surrounding cell top right
x23surrounding cell central right
x33surrounding cell bottom right
Returns
the calculated cell value for the central cell x22

Implemented in QgsAspectFilter, QgsHillshadeFilter, QgsRuggednessFilter, QgsSlopeFilter, QgsTotalCurvatureFilter, and QgsDerivativeFilter.

◆ processRaster()

QgsNineCellFilter::Result QgsNineCellFilter::processRaster ( QgsFeedback feedback = nullptr)

Starts the calculation, reads from mInputFile and stores the result in mOutputFile.

Parameters
feedbackfeedback object that receives update and that is checked for cancellation.
Returns
QgsNineCellFilter::Result::Success in case of success or error value on failure.

Definition at line 43 of file qgsninecellfilter.cpp.

◆ setCellSizeX()

void QgsNineCellFilter::setCellSizeX ( double  size)
inline

Definition at line 65 of file qgsninecellfilter.h.

◆ setCellSizeY()

void QgsNineCellFilter::setCellSizeY ( double  size)
inline

Definition at line 67 of file qgsninecellfilter.h.

◆ setCreationOptions()

void QgsNineCellFilter::setCreationOptions ( const QStringList &  list)
inline

Sets a list of data source creation options to use when creating the output raster file.

See also
creationOptions()
Since
QGIS 3.44

Definition at line 83 of file qgsninecellfilter.h.

◆ setInputNodataValue()

void QgsNineCellFilter::setInputNodataValue ( double  value)
inline

Definition at line 73 of file qgsninecellfilter.h.

◆ setOutputNodataValue()

void QgsNineCellFilter::setOutputNodataValue ( double  value)
inline

Definition at line 75 of file qgsninecellfilter.h.

◆ setZFactor()

void QgsNineCellFilter::setZFactor ( double  factor)
inline

Definition at line 70 of file qgsninecellfilter.h.

◆ zFactor()

double QgsNineCellFilter::zFactor ( ) const
inline

Definition at line 69 of file qgsninecellfilter.h.

Member Data Documentation

◆ mCellSizeX

double QgsNineCellFilter::mCellSizeX = -1.0
protected

Definition at line 172 of file qgsninecellfilter.h.

◆ mCellSizeY

double QgsNineCellFilter::mCellSizeY = -1.0
protected

Definition at line 173 of file qgsninecellfilter.h.

◆ mCreationOptions

QStringList QgsNineCellFilter::mCreationOptions
protected

Definition at line 170 of file qgsninecellfilter.h.

◆ mInputFile

QString QgsNineCellFilter::mInputFile
protected

Definition at line 167 of file qgsninecellfilter.h.

◆ mInputNodataValue

double QgsNineCellFilter::mInputNodataValue = -1.0
protected

The nodata value of the input layer.

Definition at line 175 of file qgsninecellfilter.h.

◆ mOutputFile

QString QgsNineCellFilter::mOutputFile
protected

Definition at line 168 of file qgsninecellfilter.h.

◆ mOutputFormat

QString QgsNineCellFilter::mOutputFormat
protected

Definition at line 169 of file qgsninecellfilter.h.

◆ mOutputNodataValue

double QgsNineCellFilter::mOutputNodataValue = -9999.0
protected

The nodata value of the output layer.

Definition at line 177 of file qgsninecellfilter.h.

◆ mZFactor

double QgsNineCellFilter::mZFactor = 1.0
protected

Scale factor for z-value if x-/y- units are different to z-units (111120 for degree->meters and 370400 for degree->feet)

Definition at line 179 of file qgsninecellfilter.h.


The documentation for this class was generated from the following files: