Class: QgsRasterRenderer¶
- class qgis.core.QgsRasterRenderer¶
Bases:
QgsRasterInterface
Raster renderer pipe that applies colors to a raster.
QgsRasterRenderer(input:
QgsRasterInterface
= None, type: str = ‘’) Constructor for QgsRasterRenderer.Methods
Accepts the specified symbology
visitor
, causing it to visit all symbols associated with the renderer.- rtype:
int
- rtype:
int
- param bandNo:
QgsRasterRenderer
cannot be copied.Copies common properties like opacity / transparency data from other renderer.
Creates a set of legend nodes representing the renderer.
- param bandNo:
Returns flags which dictate renderer behavior.
Fill in histogram defaults if not specified
Fill in statistics defaults if not specified
Returns symbology items if provided by renderer.
Returns const reference to origin of min/max values
Returns the color to use for shading nodata pixels.
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque).
- rtype:
QgsRasterTransparency
Sets base class members from xml.
Returns the color for the renderer to use to represent nodata pixels.
- param band:
- param input:
Sets origin of min/max values
Sets the
color
to use for shading nodata pixels.Sets the
opacity
for the renderer, whereopacity
is a value between 0 (totally transparent) and 1.0 (fully opaque).- param t:
Used from subclasses to create SLD Rule elements following SLD v1.0 specs
Returns a unique string representation of the renderer type.
Returns a list of band numbers used by the renderer
- rtype:
bool
Attributes
- NODATA_COLOR = 0¶
- accept(self, visitor: QgsStyleEntityVisitorInterface) bool ¶
Accepts the specified symbology
visitor
, causing it to visit all symbols associated with the renderer.Returns
True
if the visitor should continue visiting other objects, orFalse
if visiting should be canceled.New in version 3.10.
- Parameters:
visitor (QgsStyleEntityVisitorInterface) –
- Return type:
bool
- alphaBand(self) int ¶
- Return type:
int
- bandCount(self) int ¶
- Return type:
int
- block(self, bandNo: int, extent: QgsRectangle, width: int, height: int, feedback: QgsRasterBlockFeedback = None) QgsRasterBlock ¶
- Parameters:
bandNo (int) –
extent (QgsRectangle) –
width (int) –
height (int) –
feedback (
QgsRasterBlockFeedback
= None) –
- Return type:
- clone(self) QgsRasterRenderer ¶
QgsRasterRenderer
cannot be copied. Useclone()
instead.- Return type:
- copyCommonProperties(self, other: QgsRasterRenderer, copyMinMaxOrigin: bool = True)¶
Copies common properties like opacity / transparency data from other renderer. Useful when cloning renderers.
New in version 2.16.
- Parameters:
other (QgsRasterRenderer) –
copyMinMaxOrigin (bool = True) –
- createLegendNodes(self, nodeLayer: QgsLayerTreeLayer) List[QgsLayerTreeModelLegendNode] ¶
Creates a set of legend nodes representing the renderer.
The default implementation calls
legendSymbologyItems()
and creates corresponding legend nodes for each returned symbology item.Subclasses can override this to return more legend nodes which better represent the renderer.
New in version 3.18.
- Parameters:
nodeLayer (QgsLayerTreeLayer) –
- Return type:
- dataType(self, bandNo: int) Qgis.DataType ¶
- Parameters:
bandNo (int) –
- Return type:
- flags(self) Qgis.RasterRendererFlags ¶
Returns flags which dictate renderer behavior.
New in version 3.28.
- Return type:
- 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()
- initStatistics(self, statistics: QgsRasterBandStats, bandNo: int, stats: int = QgsRasterBandStats.All, boundingBox: QgsRectangle = QgsRectangle(), binCount: int = 0)¶
Fill in statistics defaults if not specified
- legendSymbologyItems(self) List[Tuple[str, QColor]] ¶
Returns symbology items if provided by renderer.
See also
- Return type:
List[Tuple[str, QColor]]
- minMaxOrigin(self) QgsRasterMinMaxOrigin ¶
Returns const reference to origin of min/max values
- Return type:
- nodataColor(self) QColor ¶
Returns the color to use for shading nodata pixels.
If the returned value is an invalid color then the default transparent rendering of nodata values will be used.
See also
See also
New in version 3.12.
- Return type:
QColor
- opacity(self) float ¶
Returns the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque).
See also
- Return type:
float
- rasterTransparency(self) QgsRasterTransparency ¶
- Return type:
- readXml(self, rendererElem: QDomElement)¶
Sets base class members from xml. Usually called from
create()
methods of subclasses- Parameters:
rendererElem (QDomElement) –
- renderColorForNodataPixel(self) int ¶
Returns the color for the renderer to use to represent nodata pixels.
Subclasses should use this rather then
nodataColor()
to determine the color to use for nodata pixels during an actual rendering operation.New in version 3.10.
- Return type:
int
- setAlphaBand(self, band: int)¶
- Parameters:
band (int) –
- setInput(self, input: QgsRasterInterface) bool ¶
- Parameters:
input (QgsRasterInterface) –
- Return type:
bool
- setMinMaxOrigin(self, origin: QgsRasterMinMaxOrigin)¶
Sets origin of min/max values
- Parameters:
origin (QgsRasterMinMaxOrigin) –
- setNodataColor(self, color: QColor | Qt.GlobalColor | QGradient)¶
Sets the
color
to use for shading nodata pixels.If
color
is an invalid color then the default transparent rendering of nodata values will be used.See also
New in version 3.12.
- Parameters:
color (Union[QColor) –
- setOpacity(self, opacity: float)¶
Sets the
opacity
for the renderer, whereopacity
is a value between 0 (totally transparent) and 1.0 (fully opaque).See also
- Parameters:
opacity (float) –
- setRasterTransparency(self, t: QgsRasterTransparency)¶
- Parameters:
t (QgsRasterTransparency) –
- toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any] = {})¶
Used from subclasses to create SLD Rule elements following SLD v1.0 specs
New in version 3.6.
- Parameters:
doc (QDomDocument) –
element (QDomElement) –
props (Dict[str) –
- type(self) str ¶
Returns a unique string representation of the renderer type.
- Return type:
str
- usesBands(self) List[int] ¶
Returns a list of band numbers used by the renderer
- Return type:
List[int]
- usesTransparency(self) bool ¶
- Return type:
bool