Class: QgsRasterInterface¶
- class qgis.core.QgsRasterInterface¶
Bases:
sip.wrapper
Base class for processing filters like renderers, reprojector, resampler etc.
Methods
Gets number of bands
Returns the band statistics.
Read block of data using given extent and size.
Returns a bitmask containing the supported capabilities
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
True
if histogram is available (cached, already calculated)Returns
True
if histogram is available (cached, already calculated).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
- rtype
int
- rtype
int
Attributes
- BuildPyramids = 16¶
- class Capability¶
Bases:
int
- Create = 4¶
- Identify = 32¶
- IdentifyFeature = 512¶
- IdentifyHtml = 256¶
- IdentifyText = 128¶
- IdentifyValue = 64¶
- NoCapabilities = 0¶
- Prefetch = 1024¶
- Remove = 8¶
- Size = 2¶
- bandCount(self) int ¶
Gets number of bands
- Return type
int
- bandStatistics(self, bandNo: int, stats: int = QgsRasterBandStats.All, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, feedback: QgsRasterBlockFeedback = None) QgsRasterBandStats ¶
Returns the band statistics.
- Parameters
bandNo (int) – The band (number).
stats (int = QgsRasterBandStats.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 (
QgsRasterBlockFeedback
= None) – optional feedback object
- Return type
- block(self, bandNo: int, extent: QgsRectangle, width: int, height: int, feedback: QgsRasterBlockFeedback = None) QgsRasterBlock ¶
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 (
QgsRasterBlockFeedback
= None) – optional raster feedback object for cancellation/preview. Added in QGIS 3.0.
- Return type
- capabilities(self) int ¶
Returns a bitmask containing the supported capabilities
- Return type
int
- capabilitiesString(self) str ¶
Returns the raster interface capabilities in friendly format.
- Return type
str
- clone(self) QgsRasterInterface ¶
Clone itself, create deep copy
- Return type
- colorInterpretationName(self, bandNumber: int) str ¶
Returns the name of the color interpretation for the specified
bandNumber
.New in version 3.18.
- Parameters
bandNumber (int) –
- Return type
str
- cumulativeCut(self, bandNo: int, lowerCount: float, upperCount: float, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0) Tuple[float, float] ¶
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) – 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.
- Return type
Tuple[float, float]
- dataType(self, bandNo: int) Qgis.DataType ¶
Returns data type for the band specified by number
- Parameters
bandNo (int) –
- Return type
- dataTypeSize(self, bandNo: int) int ¶
Returns the size (in bytes) for the data type for the specified band.
- Parameters
bandNo (int) –
- Return type
int
- displayBandName(self, bandNumber: int) str ¶
Generates a friendly, descriptive name for the specified
bandNumber
.New in version 3.18.
- Parameters
bandNumber (int) –
- Return type
str
- extent(self) QgsRectangle ¶
Gets the extent of the interface.
- Return type
- Returns
QgsRectangle
containing the extent of the layer
- generateBandName(self, bandNumber: int) str ¶
helper function to create zero padded band names
- Parameters
bandNumber (int) –
- Return type
str
- hasHistogram(self, bandNo: int, binCount: int, minimum: object = Py_None, maximum: object = Py_None, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False) bool ¶
Returns
True
if histogram is available (cached, already calculated)Note
the parameters are the same as in
histogram()
- Parameters
bandNo (int) –
binCount (int) –
minimum (object = Py_None) –
maximum (object = Py_None) –
extent (
QgsRectangle
= QgsRectangle()) –sampleSize (int = 0) –
includeOutOfRange (bool = False) –
- Return type
bool
- hasStatistics(self, bandNo: int, stats: int = QgsRasterBandStats.All, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0) bool ¶
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 (int = QgsRasterBandStats.All) –
extent (
QgsRectangle
= QgsRectangle()) –sampleSize (int = 0) –
- histogram(self, bandNo: int, binCount: int = 0, minimum: object = Py_None, maximum: object = Py_None, extent: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False, feedback: QgsRasterBlockFeedback = None) QgsRasterHistogram ¶
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 (object = Py_None) – Minimum value, if NaN (None for Python), raster minimum value will be used.
maximum (object = 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 (
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: object = Py_None, maximum: object = Py_None, boundingBox: QgsRectangle = QgsRectangle(), sampleSize: int = 0, includeOutOfRange: bool = False)¶
Fill in histogram defaults if not specified
Note
the parameters are the same as in
histogram()
- Parameters
histogram (QgsRasterHistogram) –
bandNo (int) –
binCount (int) –
minimum (object = Py_None) –
maximum (object = Py_None) –
boundingBox (
QgsRectangle
= QgsRectangle()) –sampleSize (int = 0) –
includeOutOfRange (bool = False) –
- initStatistics(self, statistics: QgsRasterBandStats, bandNo: int, stats: int = QgsRasterBandStats.All, boundingBox: QgsRectangle = QgsRectangle(), binCount: int = 0)¶
Fill in statistics defaults if not specified
- Parameters
statistics (QgsRasterBandStats) –
bandNo (int) –
stats (int = QgsRasterBandStats.All) –
boundingBox (
QgsRectangle
= QgsRectangle()) –binCount (int = 0) –
- input(self) QgsRasterInterface ¶
Current input
- Return type
- on(self) bool ¶
Returns whether the interface is on or off
- Return type
bool
- readXml(self, filterElem: QDomElement)¶
Sets base class members from xml. Usually called from
create()
methods of subclasses- Parameters
filterElem (QDomElement) –
- setInput(self, input: QgsRasterInterface) bool ¶
Set input. Returns
True
if set correctly,False
if cannot use that input- Parameters
input (QgsRasterInterface) –
- Return type
bool
- setOn(self, on: bool)¶
Sets whether the interface is on or off
- Parameters
on (bool) –
- sourceDataType(self, bandNo: int) Qgis.DataType ¶
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 ¶
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
- writeXml(self, doc: QDomDocument, parentElem: QDomElement)¶
Write base class members to xml.
- Parameters
doc (QDomDocument) –
parentElem (QDomElement) –
- xBlockSize(self) int ¶
Gets block size
- Return type
int
- xSize(self) int ¶
Gets raster size
- Return type
int
- yBlockSize(self) int ¶
- Return type
int
- ySize(self) int ¶
- Return type
int