Class: QgsRasterRenderer¶
Raster renderer pipe that applies colors to a raster.
Class Hierarchy¶
Base classes¶
Base class for processing filters like renderers, reprojector, resampler etc. |
Subclasses¶
A renderer for generating live hillshade models. |
|
Renderer for multiband images with the color components. |
|
Renderer for paletted raster images. |
|
Raster renderer that generates contours on the fly for a source raster band. |
|
Raster renderer which renders all data pixels using a single color. |
|
Raster renderer pipe for single band color. |
|
Raster renderer pipe for single band gray. |
|
Raster renderer pipe for single band pseudocolor. |
Methods
Copies common properties like opacity / transparency data from other 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). |
|
Returns the color for the renderer to use to represent nodata pixels. |
|
Sets origin of min/max values |
|
Sets the color to use for shading nodata pixels. |
|
Sets the opacity for the renderer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque). |
|
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsRasterRenderer. See the FAQ for more details.
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer. |
|
Returns |
|
Creates a set of legend nodes representing the renderer. |
|
Returns flags which dictate renderer behavior. |
|
Returns the input band for the renderer, or -1 if no input band is available. |
|
Returns symbology items if provided by renderer. |
|
Sets base class members from xml. |
|
Attempts to set the input band for the renderer. |
|
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. |
Attributes
- class qgis.core.QgsRasterRenderer[source]¶
Bases:
QgsRasterInterface
- __init__(input: QgsRasterInterface | None = None, type: str | None = '')
Constructor for QgsRasterRenderer.
- Parameters:
input (Optional[QgsRasterInterface] = None)
type (Optional[str] = '')
- NODATA_COLOR = 0¶
- virtual accept(self, visitor: QgsStyleEntityVisitorInterface | None) bool [source]¶
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.Added in version 3.10.
- Parameters:
visitor (Optional[QgsStyleEntityVisitorInterface])
- Return type:
bool
- virtual canCreateRasterAttributeTable(self) bool [source]¶
Returns
True
if the renderer is suitable for attribute table creation. The default implementation returnsFalse
.Added in version 3.30.
- Return type:
bool
- copyCommonProperties(self, other: QgsRasterRenderer | None, copyMinMaxOrigin: bool = True)[source]¶
Copies common properties like opacity / transparency data from other renderer. Useful when cloning renderers.
- Parameters:
other (Optional[QgsRasterRenderer])
copyMinMaxOrigin (bool = True)
- virtual createLegendNodes(self, nodeLayer: QgsLayerTreeLayer | None) 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.
Added in version 3.18.
- Parameters:
nodeLayer (Optional[QgsLayerTreeLayer])
- Return type:
- virtual flags(self) Qgis.RasterRendererFlags [source]¶
Returns flags which dictate renderer behavior.
Added in version 3.28.
- Return type:
- virtual inputBand(self) int [source]¶
Returns the input band for the renderer, or -1 if no input band is available.
For renderers which utilize multiple input bands -1 will be returned. In these cases
usesBands()
will return a list of all utilized bands (including alpha bands).See also
See also
Added in version 3.38.
- Return type:
int
- virtual 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 [source]¶
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
Added in version 3.12.
- Return type:
QColor
- opacity(self) float [source]¶
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 | None [source]¶
- Return type:
Optional[QgsRasterTransparency]
- virtual readXml(self, rendererElem: QDomElement)[source]¶
Sets base class members from xml. Usually called from
create()
methods of subclasses- Parameters:
rendererElem (QDomElement)
- renderColorForNodataPixel(self) int [source]¶
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.Added in version 3.10.
- Return type:
int
- virtual setInputBand(self, band: int) bool [source]¶
Attempts to set the input
band
for the renderer.Returns
True
if the band was successfully set, orFalse
if the band could not be set.Note
Not all renderers support setting the input band.
See also
See also
Added in version 3.38.
- Parameters:
band (int)
- Return type:
bool
- setMinMaxOrigin(self, origin: QgsRasterMinMaxOrigin)[source]¶
Sets origin of min/max values
- Parameters:
origin (QgsRasterMinMaxOrigin)
- setNodataColor(self, color: QColor | Qt.GlobalColor)[source]¶
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
Added in version 3.12.
- Parameters:
color (Union[QColor, Qt.GlobalColor])
- setOpacity(self, opacity: float)[source]¶
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 | None)[source]¶
- Parameters:
t (Optional[QgsRasterTransparency])
- virtual toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any] = {})[source]¶
Used from subclasses to create SLD Rule elements following SLD v1.0 specs
Deprecated since version 3.44: Use the version with
QgsSldExportContext
instead.- Parameters:
doc (QDomDocument)
element (QDomElement)
props (Dict[str, Any] = {})
- virtual toSld(self, doc: QDomDocument, element: QDomElement, context: QgsSldExportContext) bool [source]
Used from subclasses to create SLD Rule elements following SLD v1.0 specs
Added in version 3.44.
- Parameters:
doc (QDomDocument)
element (QDomElement)
context (
QgsSldExportContext
)
- Return type:
bool
- virtual type(self) str [source]¶
Returns a unique string representation of the renderer type.
- Return type:
str
- virtual usesBands(self) List[int] ¶
Returns a list of band numbers used by the renderer.
See also
- Return type:
List[int]