Class: QgsRasterInterface¶
Base class for processing filters like renderers, reprojector, resampler etc.
Class Hierarchy¶
Subclasses¶
Brightness/contrast and gamma correction filter pipe for rasters. |
|
Raster renderer pipe that applies colors to a raster. |
|
Color and saturation filter pipe for rasters. |
|
Base class for raster data providers. |
|
Raster pipe that deals with null values. |
|
Implements approximate projection support for optimised raster transformation. |
|
Resample filter pipe for rasters. |
Enums
alias of |
Methods
Gets number of bands |
|
Returns the band statistics. |
|
Read block of data using given extent and size. |
|
Returns the capabilities supported by the interface. |
|
Returns the raster interface capabilities in friendly format. |
|
Clone itself, create deep copy |
|
Returns the name of the color interpretation for the specified bandNumber. |
|
Find values for cumulative pixel count cut. |
|
Returns data type for the band specified by number |
|
Returns the size (in bytes) for the data type for the specified band. |
|
Generates a friendly, descriptive name for the specified bandNumber. |
|
Gets the extent of the interface. |
|
helper function to create zero padded band names |
|
Returns |
|
Returns |
|
Returns a band histogram. |
|
Fill in histogram defaults if not specified |
|
Fill in statistics defaults if not specified |
|
Current input |
|
Returns whether the interface is on or off |
|
Sets base class members from xml. |
|
Set input. |
|
Sets whether the interface is on or off |
|
Returns source data type for the band specified by number, source data type may be shorter than dataType |
|
Gets source / raw input, the first in pipe, usually provider. |
|
Write base class members to xml. |
|
Gets block size |
|
Gets raster size |
|
- class qgis.core.QgsRasterInterface[source]¶
Bases:
object
- Capability¶
alias of
RasterInterfaceCapability
- bandStatistics(self, bandNo: int, stats: int, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, feedback: QgsRasterBlockFeedback | None = None) QgsRasterBandStats [source]¶
Returns the band statistics.
- Parameters:
bandNo (int) – The band (number).
stats (int) – Requested statistics
extent (
QgsRectangle
= QgsRectangle()) – Extent used to calc statistics, if empty, whole raster extent is used.sampleSize (int = 0) – 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[QgsRasterBlockFeedback] = None) – optional feedback object
Deprecated since version 3.40: Use
Qgis
.RasterBandStatistic instead of int forstats
argument.- Return type:
- bandStatistics(self, bandNo: int, stats: Qgis.RasterBandStatistics | Qgis.RasterBandStatistic = Qgis.RasterBandStatistic.All, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, feedback: QgsRasterBlockFeedback | None = None) QgsRasterBandStats [source]
Returns the band statistics.
- Parameters:
bandNo (int) – The band (number).
stats (Union[Qgis.RasterBandStatistics, Qgis.RasterBandStatistic] = Qgis.RasterBandStatistic.All) – Requested statistics
extent (
QgsRectangle
= QgsRectangle()) – Extent used to calc statistics, if empty, whole raster extent is used.sampleSize (int = 0) – 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[QgsRasterBlockFeedback] = None) – optional feedback object
- Return type:
- block(self, bandNo: int, extent: QgsRectangle, width: int, height: int, feedback: QgsRasterBlockFeedback | None = None) QgsRasterBlock | None [source]¶
Read block of data using given extent and size. Returns pointer to data. Caller is responsible to free the memory returned.
- Parameters:
bandNo (int) – band number
extent (QgsRectangle) – extent of block
width (int) – pixel width of block
height (int) – pixel height of block
feedback (Optional[QgsRasterBlockFeedback] = None) – optional raster feedback object for cancellation/preview. Added in QGIS 3.0.
- Return type:
Optional[QgsRasterBlock]
- capabilities(self) Qgis.RasterInterfaceCapabilities [source]¶
Returns the capabilities supported by the interface.
- Return type:
- capabilitiesString(self) str [source]¶
Returns the raster interface capabilities in friendly format.
Deprecated since version 3.40: Will be removed in QGIS 4.0.
- Return type:
str
- clone(self) QgsRasterInterface | None [source]¶
Clone itself, create deep copy
- Return type:
Optional[QgsRasterInterface]
- colorInterpretationName(self, bandNumber: int) str [source]¶
Returns the name of the color interpretation for the specified
bandNumber
. It is translated since QGIS 3.40Added in version 3.18.
- Parameters:
bandNumber (int)
- Return type:
str
- cumulativeCut(self, bandNo: int, lowerCount: float, upperCount: float, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0)[source]¶
Find values for cumulative pixel count cut.
- Parameters:
bandNo (int) – The band (number).
lowerCount (float) – The lower count as fraction of 1, e.g. 0.02 = 2%
upperCount (float) – 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 (
QgsRectangle
= QgsRectangle()) – Extent used to calc histogram, if empty, whole raster extent is used.sampleSize (int = 0) -> (float) – 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.
- dataType(self, bandNo: int) Qgis.DataType [source]¶
Returns data type for the band specified by number
- Parameters:
bandNo (int)
- Return type:
- dataTypeSize(self, bandNo: int) int [source]¶
Returns the size (in bytes) for the data type for the specified band.
- Parameters:
bandNo (int)
- Return type:
int
- displayBandName(self, bandNumber: int) str [source]¶
Generates a friendly, descriptive name for the specified
bandNumber
.Added in version 3.18.
- Parameters:
bandNumber (int)
- Return type:
str
- extent(self) QgsRectangle [source]¶
Gets the extent of the interface.
- Return type:
- Returns:
QgsRectangle
containing the extent of the layer
- generateBandName(self, bandNumber: int) str [source]¶
helper function to create zero padded band names
- Parameters:
bandNumber (int)
- Return type:
str
- hasHistogram(self, bandNo: int, binCount: int, minimum: Any = Py_None, maximum: Any = Py_None, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False) bool [source]¶
Returns
True
if histogram is available (cached, already calculated)Note
the parameters are the same as in
histogram()
- Parameters:
bandNo (int)
binCount (int)
minimum (Any = Py_None)
maximum (Any = Py_None)
extent (
QgsRectangle
= QgsRectangle())sampleSize (int = 0)
includeOutOfRange (bool = False)
- Return type:
bool
- hasStatistics(self, bandNo: int, stats: int, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0) bool [source]¶
Returns
True
if histogram is available (cached, already calculated). The parameters are the same as inbandStatistics()
- Return type:
bool
- Returns:
True
if statistics are available (ready to use)
Deprecated since version 3.40: Use
Qgis
.RasterBandStatistic instead of int forstats
argument.- Parameters:
bandNo (int)
stats (int)
extent (
QgsRectangle
= QgsRectangle())sampleSize (int = 0)
- hasStatistics(self, bandNo: int, stats: Qgis.RasterBandStatistics | Qgis.RasterBandStatistic = Qgis.RasterBandStatistic.All, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0) bool [source]
Returns
True
if histogram is available (cached, already calculated). The parameters are the same as inbandStatistics()
- Return type:
bool
- Returns:
True
if statistics are available (ready to use)- Parameters:
bandNo (int)
stats (Union[Qgis.RasterBandStatistics, Qgis.RasterBandStatistic] = Qgis.RasterBandStatistic.All)
extent (
QgsRectangle
= QgsRectangle())sampleSize (int = 0)
- histogram(self, bandNo: int, binCount: int = 0, minimum: Any = Py_None, maximum: Any = Py_None, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False, feedback: QgsRasterBlockFeedback | None = None) QgsRasterHistogram [source]¶
Returns a band histogram. Histograms are cached in providers.
- Parameters:
bandNo (int) – The band (number).
binCount (int = 0) – Number of bins (intervals,buckets). If 0, the number of bins is decided automatically according to data type, raster size etc.
minimum (Any = Py_None) – Minimum value, if NaN (None for Python), raster minimum value will be used.
maximum (Any = Py_None) – Maximum value, if NaN (None for Python), raster maximum value will be used.
extent (
QgsRectangle
= QgsRectangle()) – Extent used to calc histogram, if empty, whole raster extent is used.sampleSize (int = 0) – 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 (bool = False) – include out of range values
feedback (Optional[QgsRasterBlockFeedback] = None) – optional feedback object
- Return type:
- Returns:
Vector of non NULL cell counts for each bin.
Note
binCount, minimum and maximum not optional in Python bindings
- initHistogram(self, histogram: QgsRasterHistogram, bandNo: int, binCount: int, minimum: Any = Py_None, maximum: Any = Py_None, boundingBox: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False)[source]¶
Fill in histogram defaults if not specified
Note
the parameters are the same as in
histogram()
- Parameters:
histogram (QgsRasterHistogram)
bandNo (int)
binCount (int)
minimum (Any = Py_None)
maximum (Any = Py_None)
boundingBox (
QgsRectangle
= QgsRectangle())sampleSize (int = 0)
includeOutOfRange (bool = False)
- initStatistics(self, statistics: QgsRasterBandStats, bandNo: int, stats: int, boundingBox: QgsRectangle = QgsRectangle(), binCount: int = 0)[source]¶
Fill in statistics defaults if not specified
Deprecated since version 3.40: Use
Qgis
.RasterBandStatistic instead of int forstats
argument.- Parameters:
statistics (
QgsRasterBandStats
)bandNo (int)
stats (int)
boundingBox (
QgsRectangle
= QgsRectangle())binCount (int = 0)
- initStatistics(self, statistics: QgsRasterBandStats, bandNo: int, stats: Qgis.RasterBandStatistics | Qgis.RasterBandStatistic = Qgis.RasterBandStatistic.All, boundingBox: QgsRectangle = QgsRectangle(), binCount: int = 0)[source]
Fill in statistics defaults if not specified
- Parameters:
statistics (
QgsRasterBandStats
)bandNo (int)
stats (Union[Qgis.RasterBandStatistics, Qgis.RasterBandStatistic] = Qgis.RasterBandStatistic.All)
boundingBox (
QgsRectangle
= QgsRectangle())binCount (int = 0)
- input(self) QgsRasterInterface | None [source]¶
Current input
- Return type:
Optional[QgsRasterInterface]
- readXml(self, filterElem: QDomElement)[source]¶
Sets base class members from xml. Usually called from
create()
methods of subclasses- Parameters:
filterElem (QDomElement)
- setInput(self, input: QgsRasterInterface | None) bool [source]¶
Set input. Returns
True
if set correctly,False
if cannot use that input- Parameters:
input (Optional[QgsRasterInterface])
- Return type:
bool
- sourceDataType(self, bandNo: int) Qgis.DataType [source]¶
Returns source data type for the band specified by number, source data type may be shorter than dataType
- Parameters:
bandNo (int)
- Return type:
- sourceInput(self) QgsRasterInterface | None [source]¶
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.
- Return type:
Optional[QgsRasterInterface]