QgsRasterInterface class
Base class for processing filters like renderers, reprojector, resampler etc.
Contents
Derived classes
- class QgsBrightnessContrastFilter
- Brightness/contrast filter pipe for rasters.
- class QgsHueSaturationFilter
- Color and saturation filter pipe for rasters.
- class QgsRasterDataProvider
- Base class for raster data providers.
- class QgsRasterNuller
- Raster pipe that deals with null values.
- class QgsRasterProjector
- QgsRasterProjector implements approximate projection support for it calculates grid of points in source CRS for target CRS + extent which are used to calculate affine transformation matrices.
- class QgsRasterRenderer
- Raster renderer pipe that applies colors to a raster.
- class QgsRasterResampleFilter
- Resample filter pipe for rasters.
Public types
- enum Capability { NoCapabilities = 0, Size = 1 << 1, Create = 1 << 2, Remove = 1 << 3, BuildPyramids = 1 << 4, Identify = 1 << 5, IdentifyValue = 1 << 6, IdentifyText = 1 << 7, IdentifyHtml = 1 << 8, IdentifyFeature = 1 << 9 }
- If you add to this, please also add to capabilitiesString()
Public functions
- auto bandCount() const -> int pure virtual
- Gets number of bands.
-
auto bandStatistics(int bandNo,
int stats = QgsRasterBandStats::
All, const QgsRectangle& extent = QgsRectangle(), int sampleSize = 0, QgsRasterBlockFeedback* feedback = nullptr) -> QgsRasterBandStats virtual - Returns the band statistics.
- auto block(int bandNo, const QgsRectangle& extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr) -> QgsRasterBlock* pure virtual
- Read block of data using given extent and size.
- auto capabilities() const -> int virtual
- Returns a bitmask containing the supported capabilities.
- auto capabilitiesString() const -> QString
- Returns the above in friendly format.
- auto clone() const -> QgsRasterInterface* pure virtual
- Clone itself, create deep copy.
- void 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.
-
auto dataType(int bandNo) const -> Qgis::
DataType pure virtual - Returns data type for the band specified by number.
- auto extent() const -> QgsRectangle virtual
- Gets the extent of the interface.
- auto generateBandName(int bandNumber) const -> QString virtual
- helper function to create zero padded band names
- auto 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) -> bool virtual
- Returns true if histogram is available (cached, already calculated)
-
auto hasStatistics(int bandNo,
int stats = QgsRasterBandStats::
All, const QgsRectangle& extent = QgsRectangle(), int sampleSize = 0) -> bool virtual - Returns true if histogram is available (cached, already calculated).
- auto 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) -> QgsRasterHistogram virtual
- Returns a band histogram.
- auto input() const -> QgsRasterInterface* virtual
- Current input.
- auto on() const -> bool virtual
- Returns whether the interface is on or off.
- void readXml(const QDomElement& filterElem) virtual
- Sets base class members from xml. Usually called from create() methods of subclasses.
- auto setInput(QgsRasterInterface* input) -> bool virtual
- Set input.
- void setOn(bool on) virtual
- Sets whether the interface is on or off.
-
auto sourceDataType(int bandNo) const -> Qgis::
DataType virtual - Returns source data type for the band specified by number, source data type may be shorter than dataType.
- auto sourceInput() const -> const QgsRasterInterface* virtual
- Gets source / raw input, the first in pipe, usually provider.
- auto sourceInput() -> QgsRasterInterface* virtual
- Gets source / raw input, the first in pipe, usually provider.
- void writeXml(QDomDocument& doc, QDomElement& parentElem) const virtual
- Write base class members to xml.
- auto xBlockSize() const -> int virtual
- Gets block size.
- auto xSize() const -> int virtual
- Gets raster size.
Protected 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.
-
void initStatistics(QgsRasterBandStats& statistics,
int bandNo,
int stats = QgsRasterBandStats::
All, const QgsRectangle& boundingBox = QgsRectangle(), int binCount = 0) - Fill in statistics defaults if not specified.
Protected variables
- QList<QgsRasterHistogram> mHistograms
- List of cached histograms, all bands mixed.
- QList<QgsRasterBandStats> mStatistics
- List of cached statistics, all bands mixed.
Function documentation
QgsRasterBandStats QgsRasterInterface:: bandStatistics(int bandNo,
int stats = QgsRasterBandStats:: All,
const QgsRectangle& extent = QgsRectangle(),
int sampleSize = 0,
QgsRasterBlockFeedback* feedback = nullptr) virtual
Returns the band statistics.
| Parameters | |
|---|---|
| bandNo | The band (number). |
| stats | Requested statistics |
| extent | Extent used to calc statistics, if empty, whole raster extent is used. |
| sampleSize | Approximate 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. |
| feedback | optional feedback object |
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.
| Parameters | |
|---|---|
| bandNo | band number |
| extent | extent of block |
| width | pixel width of block |
| height | pixel height of block |
| feedback | optional raster feedback object for cancelation/preview. Added in QGIS 3.0. |
Returns pointer to data. Caller is responsible to free the memory returned.
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 | |
|---|---|
| bandNo | The band (number). |
| lowerCount | The lower count as fraction of 1, e.g. 0.02 = 2% |
| upperCount | The upper count as fraction of 1, e.g. 0.98 = 98% |
| lowerValue | Location into which the lower value will be set. |
| upperValue | Location into which the upper value will be set. |
| extent | Extent used to calc histogram, if empty, whole raster extent is used. |
| sampleSize | Approximate 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. |
QgsRectangle QgsRasterInterface:: extent() const virtual
Gets the extent of the interface.
| Returns | QgsRectangle containing the extent of the layer |
|---|
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)
bool QgsRasterInterface:: hasStatistics(int bandNo,
int stats = QgsRasterBandStats:: All,
const QgsRectangle& extent = QgsRectangle(),
int sampleSize = 0) virtual
Returns true if histogram is available (cached, already calculated).
| Returns | true if statistics are available (ready to use) |
|---|
- The parameters are the same as in bandStatistics()
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.
| Parameters | |
|---|---|
| bandNo | The band (number). |
| binCount | Number of bins (intervals,buckets). If 0, the number of bins is decided automatically according to data type, raster size etc. |
| minimum | Minimum value, if NaN (None for Python), raster minimum value will be used. |
| maximum | Maximum value, if NaN (None for Python), raster maximum value will be used. |
| extent | Extent used to calc histogram, if empty, whole raster extent is used. |
| sampleSize | Approximate 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. |
| includeOutOfRange | include out of range values |
| feedback | optional feedback object |
| Returns | Vector of non NULL cell counts for each bin. |
Histograms are cached in providers.
bool QgsRasterInterface:: setInput(QgsRasterInterface* input) virtual
Set input.
Returns true if set correctly, false if cannot use that input
const QgsRasterInterface* QgsRasterInterface:: sourceInput() const virtual
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.
QgsRasterInterface* QgsRasterInterface:: sourceInput() virtual
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.
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.