Class: QgsRasterRenderer

class qgis.core.QgsRasterRenderer(input: QgsRasterInterface = None, type: str = '')

Bases: QgsRasterInterface

Constructor for QgsRasterRenderer.

Raster renderer pipe that applies colors to a raster.

Parameters
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, or False 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
Return type

QgsRasterBlock

clone(self)QgsRasterRenderer

QgsRasterRenderer cannot be copied. Use clone() instead.

Return type

QgsRasterRenderer

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
dataType(self, bandNo: int) → Qgis.DataType
Parameters

bandNo (int) –

Return type

Qgis.DataType

initHistogram()
initStatistics()
legendSymbologyItems(self) → List[Tuple[str, QColor]]

Gets symbology items if provided by renderer

Return type

List[Tuple[str, QColor]]

minMaxOrigin(self)QgsRasterMinMaxOrigin

Returns const reference to origin of min/max values

Return type

QgsRasterMinMaxOrigin

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

setOpacity()

Return type

float

rasterTransparency(self)QgsRasterTransparency
Return type

QgsRasterTransparency

readXml(self, rendererElem: QDomElement)

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

Parameters

rendererElem (QDomElement) –

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) –

setOpacity(self, opacity: float)

Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque).

See also

opacity()

Parameters

opacity (float) –

setRasterTransparency(self, t: QgsRasterTransparency)
Parameters

t (QgsRasterTransparency) –

toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, str] = {})

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
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