QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsRasterInterface Class Referenceabstract

Base class for processing filters like renderers, reprojector, resampler etc. More...

#include <qgsrasterinterface.h>

Inheritance diagram for QgsRasterInterface:
Inheritance graph
[legend]

Public Member Functions

 QgsRasterInterface (QgsRasterInterface *input=nullptr)
 
virtual ~QgsRasterInterface ()=default
 
virtual int bandCount () const =0
 Gets number of bands.
 
Q_DECL_DEPRECATED QgsRasterBandStats bandStatistics (int bandNo, int stats, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
 Returns the band statistics.
 
virtual QgsRasterBandStats bandStatistics (int bandNo, Qgis::RasterBandStatistics stats=Qgis::RasterBandStatistic::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
 Returns the band statistics.
 
virtual QgsRasterBlockblock (int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)=0
 Read block of data using given extent and size.
 
virtual Qgis::RasterInterfaceCapabilities capabilities () const
 Returns the capabilities supported by the interface.
 
Q_DECL_DEPRECATED QString capabilitiesString () const
 Returns the raster interface capabilities in friendly format.
 
virtual QgsRasterInterfaceclone () const =0
 Clone itself, create deep copy.
 
virtual QString colorInterpretationName (int bandNumber) const
 Returns the name of the color interpretation for the specified bandNumber.
 
virtual void cumulativeCut (int bandNo, double lowerCount, double upperCount, double &lowerValue, double &upperValue, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
 Find values for cumulative pixel count cut.
 
virtual Qgis::DataType dataType (int bandNo) const =0
 Returns data type for the band specified by number.
 
int dataTypeSize (int bandNo) const
 Returns the size (in bytes) for the data type for the specified band.
 
QString displayBandName (int bandNumber) const
 Generates a friendly, descriptive name for the specified bandNumber.
 
virtual QgsRectangle extent () const
 Gets the extent of the interface.
 
virtual QString generateBandName (int bandNumber) const
 helper function to create zero padded band names
 
virtual bool hasHistogram (int bandNo, int binCount, double minimum=std::numeric_limits< double >::quiet_NaN(), double maximum=std::numeric_limits< double >::quiet_NaN(), const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, bool includeOutOfRange=false)
 Returns true if histogram is available (cached, already calculated)
 
Q_DECL_DEPRECATED bool hasStatistics (int bandNo, int stats, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
 Returns true if histogram is available (cached, already calculated).
 
virtual bool hasStatistics (int bandNo, Qgis::RasterBandStatistics stats=Qgis::RasterBandStatistic::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0)
 Returns true if histogram is available (cached, already calculated).
 
virtual QgsRasterHistogram histogram (int bandNo, int binCount=0, double minimum=std::numeric_limits< double >::quiet_NaN(), double maximum=std::numeric_limits< double >::quiet_NaN(), const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, bool includeOutOfRange=false, QgsRasterBlockFeedback *feedback=nullptr)
 Returns a band histogram.
 
virtual QgsRasterInterfaceinput () const
 Current input.
 
virtual bool on () const
 Returns whether the interface is on or off.
 
virtual void readXml (const QDomElement &filterElem)
 Sets base class members from xml. Usually called from create() methods of subclasses.
 
virtual bool setInput (QgsRasterInterface *input)
 Set input.
 
virtual void setOn (bool on)
 Sets whether the interface is on or off.
 
virtual Qgis::DataType sourceDataType (int bandNo) const
 Returns source data type for the band specified by number, source data type may be shorter than dataType.
 
virtual QgsRasterInterfacesourceInput ()
 Gets source / raw input, the first in pipe, usually provider.
 
virtual const QgsRasterInterfacesourceInput () const
 Gets source / raw input, the first in pipe, usually provider.
 
virtual void writeXml (QDomDocument &doc, QDomElement &parentElem) const
 Write base class members to xml.
 
virtual int xBlockSize () const
 Gets block size.
 
virtual int xSize () const
 Gets raster size.
 
virtual int yBlockSize () const
 
virtual int ySize () const
 

Protected Member Functions

void initHistogram (QgsRasterHistogram &histogram, int bandNo, int binCount, double minimum=std::numeric_limits< double >::quiet_NaN(), double maximum=std::numeric_limits< double >::quiet_NaN(), const QgsRectangle &boundingBox=QgsRectangle(), int sampleSize=0, bool includeOutOfRange=false)
 Fill in histogram defaults if not specified.
 
Q_DECL_DEPRECATED void initStatistics (QgsRasterBandStats &statistics, int bandNo, int stats, const QgsRectangle &boundingBox=QgsRectangle(), int binCount=0) const
 Fill in statistics defaults if not specified.
 
void initStatistics (QgsRasterBandStats &statistics, int bandNo, Qgis::RasterBandStatistics stats=Qgis::RasterBandStatistic::All, const QgsRectangle &boundingBox=QgsRectangle(), int binCount=0) const
 Fill in statistics defaults if not specified.
 

Protected Attributes

QList< QgsRasterHistogrammHistograms
 List of cached histograms, all bands mixed.
 
QgsRasterInterfacemInput = nullptr
 
bool mOn = true
 
QList< QgsRasterBandStatsmStatistics
 List of cached statistics, all bands mixed.
 

Detailed Description

Base class for processing filters like renderers, reprojector, resampler etc.

Definition at line 135 of file qgsrasterinterface.h.

Constructor & Destructor Documentation

◆ QgsRasterInterface()

QgsRasterInterface::QgsRasterInterface ( QgsRasterInterface input = nullptr)

Definition at line 32 of file qgsrasterinterface.cpp.

◆ ~QgsRasterInterface()

virtual QgsRasterInterface::~QgsRasterInterface ( )
virtualdefault

Member Function Documentation

◆ bandCount()

virtual int QgsRasterInterface::bandCount ( ) const
pure virtual

◆ bandStatistics() [1/2]

QgsRasterBandStats QgsRasterInterface::bandStatistics ( int  bandNo,
int  stats,
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0,
QgsRasterBlockFeedback feedback = nullptr 
)

Returns the band statistics.

Parameters
bandNoThe band (number).
statsRequested statistics
extentExtent used to calc statistics, if empty, whole raster extent is used.
sampleSizeApproximate number of cells in sample. If 0, all cells (whole raster will be used). If raster does not have exact size (WCS without exact size for example), provider decides size of sample.
feedbackoptional feedback object
Deprecated:
QGIS 3.40. Use Qgis::RasterBandStatistic instead of int for stats argument.

Definition at line 653 of file qgsrasterinterface.cpp.

◆ bandStatistics() [2/2]

QgsRasterBandStats QgsRasterInterface::bandStatistics ( int  bandNo,
Qgis::RasterBandStatistics  stats = Qgis::RasterBandStatistic::All,
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0,
QgsRasterBlockFeedback feedback = nullptr 
)
virtual

Returns the band statistics.

Parameters
bandNoThe band (number).
statsRequested statistics
extentExtent used to calc statistics, if empty, whole raster extent is used.
sampleSizeApproximate number of cells in sample. If 0, all cells (whole raster will be used). If raster does not have exact size (WCS without exact size for example), provider decides size of sample.
feedbackoptional feedback object

Definition at line 122 of file qgsrasterinterface.cpp.

◆ block()

virtual QgsRasterBlock * QgsRasterInterface::block ( int  bandNo,
const QgsRectangle extent,
int  width,
int  height,
QgsRasterBlockFeedback feedback = nullptr 
)
pure virtual

Read block of data using given extent and size.

Returns pointer to data. Caller is responsible to free the memory returned.

Parameters
bandNoband number
extentextent of block
widthpixel width of block
heightpixel height of block
feedbackoptional raster feedback object for cancellation/preview. Added in QGIS 3.0.

Implemented in QgsRasterDataProvider, QgsBrightnessContrastFilter, QgsHillshadeRenderer, QgsHueSaturationFilter, QgsMultiBandColorRenderer, QgsPalettedRasterRenderer, QgsRasterContourRenderer, QgsRasterNuller, QgsRasterProjector, QgsRasterResampleFilter, QgsRasterSingleColorRenderer, QgsSingleBandColorDataRenderer, QgsSingleBandGrayRenderer, QgsSingleBandPseudoColorRenderer, and QgsRasterRenderer.

◆ capabilities()

Qgis::RasterInterfaceCapabilities QgsRasterInterface::capabilities ( ) const
virtual

Returns the capabilities supported by the interface.

Definition at line 37 of file qgsrasterinterface.cpp.

◆ capabilitiesString()

QString QgsRasterInterface::capabilitiesString ( ) const

Returns the raster interface capabilities in friendly format.

Deprecated:
QGIS 3.40. Will be removed in QGIS 4.0.

Definition at line 600 of file qgsrasterinterface.cpp.

◆ clone()

virtual QgsRasterInterface * QgsRasterInterface::clone ( ) const
pure virtual

◆ colorInterpretationName()

QString QgsRasterInterface::colorInterpretationName ( int  bandNumber) const
virtual

Returns the name of the color interpretation for the specified bandNumber.

It is translated since QGIS 3.40

Since
QGIS 3.18

Reimplemented in QgsRasterDataProvider.

Definition at line 634 of file qgsrasterinterface.cpp.

◆ cumulativeCut()

void QgsRasterInterface::cumulativeCut ( int  bandNo,
double  lowerCount,
double  upperCount,
double &  lowerValue,
double &  upperValue,
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0 
)
virtual

Find values for cumulative pixel count cut.

Parameters
bandNoThe band (number).
lowerCountThe lower count as fraction of 1, e.g. 0.02 = 2%
upperCountThe upper count as fraction of 1, e.g. 0.98 = 98%
lowerValueLocation into which the lower value will be set.
upperValueLocation into which the upper value will be set.
extentExtent used to calc histogram, if empty, whole raster extent is used.
sampleSizeApproximate number of cells in sample. If 0, all cells (whole raster will be used). If raster does not have exact size (WCS without exact size for example), provider decides size of sample.

Definition at line 538 of file qgsrasterinterface.cpp.

◆ dataType()

virtual Qgis::DataType QgsRasterInterface::dataType ( int  bandNo) const
pure virtual

◆ dataTypeSize()

int QgsRasterInterface::dataTypeSize ( int  bandNo) const
inline

Returns the size (in bytes) for the data type for the specified band.

Definition at line 245 of file qgsrasterinterface.h.

◆ displayBandName()

QString QgsRasterInterface::displayBandName ( int  bandNumber) const

Generates a friendly, descriptive name for the specified bandNumber.

Since
QGIS 3.18

Definition at line 642 of file qgsrasterinterface.cpp.

◆ extent()

virtual QgsRectangle QgsRasterInterface::extent ( ) const
inlinevirtual

Gets the extent of the interface.

Returns
QgsRectangle containing the extent of the layer

Reimplemented in QgsRasterDataProvider.

Definition at line 240 of file qgsrasterinterface.h.

◆ generateBandName()

QString QgsRasterInterface::generateBandName ( int  bandNumber) const
virtual

helper function to create zero padded band names

Definition at line 625 of file qgsrasterinterface.cpp.

◆ hasHistogram()

bool QgsRasterInterface::hasHistogram ( int  bandNo,
int  binCount,
double  minimum = std::numeric_limits<double>::quiet_NaN(),
double  maximum = std::numeric_limits<double>::quiet_NaN(),
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0,
bool  includeOutOfRange = false 
)
virtual

Returns true if histogram is available (cached, already calculated)

Note
the parameters are the same as in
See also
histogram()

Definition at line 392 of file qgsrasterinterface.cpp.

◆ hasStatistics() [1/2]

bool QgsRasterInterface::hasStatistics ( int  bandNo,
int  stats,
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0 
)

Returns true if histogram is available (cached, already calculated).

The parameters are the same as in bandStatistics()

Returns
true if statistics are available (ready to use)
Deprecated:
QGIS 3.40. Use Qgis::RasterBandStatistic instead of int for stats argument.

Definition at line 255 of file qgsrasterinterface.cpp.

◆ hasStatistics() [2/2]

bool QgsRasterInterface::hasStatistics ( int  bandNo,
Qgis::RasterBandStatistics  stats = Qgis::RasterBandStatistic::All,
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0 
)
virtual

Returns true if histogram is available (cached, already calculated).

The parameters are the same as in bandStatistics()

Returns
true if statistics are available (ready to use)

Definition at line 99 of file qgsrasterinterface.cpp.

◆ histogram()

QgsRasterHistogram QgsRasterInterface::histogram ( int  bandNo,
int  binCount = 0,
double  minimum = std::numeric_limits<double>::quiet_NaN(),
double  maximum = std::numeric_limits<double>::quiet_NaN(),
const QgsRectangle extent = QgsRectangle(),
int  sampleSize = 0,
bool  includeOutOfRange = false,
QgsRasterBlockFeedback feedback = nullptr 
)
virtual

Returns a band histogram.

Histograms are cached in providers.

Parameters
bandNoThe band (number).
binCountNumber of bins (intervals,buckets). If 0, the number of bins is decided automatically according to data type, raster size etc.
minimumMinimum value, if NaN (None for Python), raster minimum value will be used.
maximumMaximum value, if NaN (None for Python), raster maximum value will be used.
extentExtent used to calc histogram, if empty, whole raster extent is used.
sampleSizeApproximate number of cells in sample. If 0, all cells (whole raster will be used). If raster does not have exact size (WCS without exact size for example), provider decides size of sample.
includeOutOfRangeinclude out of range values
feedbackoptional feedback object
Returns
Vector of non NULL cell counts for each bin.
Note
binCount, minimum and maximum not optional in Python bindings

Definition at line 419 of file qgsrasterinterface.cpp.

◆ initHistogram()

void QgsRasterInterface::initHistogram ( QgsRasterHistogram histogram,
int  bandNo,
int  binCount,
double  minimum = std::numeric_limits<double>::quiet_NaN(),
double  maximum = std::numeric_limits<double>::quiet_NaN(),
const QgsRectangle boundingBox = QgsRectangle(),
int  sampleSize = 0,
bool  includeOutOfRange = false 
)
protected

Fill in histogram defaults if not specified.

Note
the parameters are the same as in
See also
histogram()

Definition at line 260 of file qgsrasterinterface.cpp.

◆ initStatistics() [1/2]

void QgsRasterInterface::initStatistics ( QgsRasterBandStats statistics,
int  bandNo,
int  stats,
const QgsRectangle boundingBox = QgsRectangle(),
int  binCount = 0 
) const
protected

Fill in statistics defaults if not specified.

Deprecated:
QGIS 3.40. Use Qgis::RasterBandStatistic instead of int for stats argument.

Definition at line 387 of file qgsrasterinterface.cpp.

◆ initStatistics() [2/2]

void QgsRasterInterface::initStatistics ( QgsRasterBandStats statistics,
int  bandNo,
Qgis::RasterBandStatistics  stats = Qgis::RasterBandStatistic::All,
const QgsRectangle boundingBox = QgsRectangle(),
int  binCount = 0 
) const
protected

Fill in statistics defaults if not specified.

Definition at line 42 of file qgsrasterinterface.cpp.

◆ input()

virtual QgsRasterInterface * QgsRasterInterface::input ( ) const
inlinevirtual

Current input.

Definition at line 295 of file qgsrasterinterface.h.

◆ on()

virtual bool QgsRasterInterface::on ( ) const
inlinevirtual

Returns whether the interface is on or off.

Definition at line 298 of file qgsrasterinterface.h.

◆ readXml()

virtual void QgsRasterInterface::readXml ( const QDomElement &  filterElem)
inlinevirtual

Sets base class members from xml. Usually called from create() methods of subclasses.

Reimplemented in QgsBrightnessContrastFilter, QgsHueSaturationFilter, QgsRasterDataProvider, QgsRasterResampleFilter, and QgsRasterRenderer.

Definition at line 509 of file qgsrasterinterface.h.

◆ setInput()

virtual bool QgsRasterInterface::setInput ( QgsRasterInterface input)
inlinevirtual

Set input.

Returns true if set correctly, false if cannot use that input

Reimplemented in QgsBrightnessContrastFilter, QgsHueSaturationFilter, QgsRasterDataProvider, QgsRasterRenderer, QgsRasterResampleFilter, and QgsSingleBandColorDataRenderer.

Definition at line 292 of file qgsrasterinterface.h.

◆ setOn()

virtual void QgsRasterInterface::setOn ( bool  on)
inlinevirtual

Sets whether the interface is on or off.

Definition at line 301 of file qgsrasterinterface.h.

◆ sourceDataType()

virtual Qgis::DataType QgsRasterInterface::sourceDataType ( int  bandNo) const
inlinevirtual

Returns source data type for the band specified by number, source data type may be shorter than dataType.

Reimplemented in QgsRasterDataProvider.

Definition at line 234 of file qgsrasterinterface.h.

◆ sourceInput() [1/2]

virtual QgsRasterInterface * QgsRasterInterface::sourceInput ( )
inlinevirtual

Gets source / raw input, the first in pipe, usually provider.

It may be used to get info about original data, e.g. resolution to decide resampling etc.

Definition at line 320 of file qgsrasterinterface.h.

◆ sourceInput() [2/2]

virtual const QgsRasterInterface * QgsRasterInterface::sourceInput ( ) const
inlinevirtual

Gets source / raw input, the first in pipe, usually provider.

It may be used to get info about original data, e.g. resolution to decide resampling etc.

Note
not available in Python bindings.

Definition at line 309 of file qgsrasterinterface.h.

◆ writeXml()

virtual void QgsRasterInterface::writeXml ( QDomDocument &  doc,
QDomElement &  parentElem 
) const
inlinevirtual

◆ xBlockSize()

virtual int QgsRasterInterface::xBlockSize ( ) const
inlinevirtual

Gets block size.

Definition at line 251 of file qgsrasterinterface.h.

◆ xSize()

virtual int QgsRasterInterface::xSize ( ) const
inlinevirtual

Gets raster size.

Definition at line 255 of file qgsrasterinterface.h.

◆ yBlockSize()

virtual int QgsRasterInterface::yBlockSize ( ) const
inlinevirtual

Definition at line 252 of file qgsrasterinterface.h.

◆ ySize()

virtual int QgsRasterInterface::ySize ( ) const
inlinevirtual

Definition at line 256 of file qgsrasterinterface.h.

Member Data Documentation

◆ mHistograms

QList<QgsRasterHistogram> QgsRasterInterface::mHistograms
protected

List of cached histograms, all bands mixed.

Definition at line 519 of file qgsrasterinterface.h.

◆ mInput

QgsRasterInterface* QgsRasterInterface::mInput = nullptr
protected

Definition at line 513 of file qgsrasterinterface.h.

◆ mOn

bool QgsRasterInterface::mOn = true
protected

Definition at line 522 of file qgsrasterinterface.h.

◆ mStatistics

QList<QgsRasterBandStats> QgsRasterInterface::mStatistics
protected

List of cached statistics, all bands mixed.

Definition at line 516 of file qgsrasterinterface.h.


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