Class: QgsPalettedRasterRenderer¶
- class qgis.core.QgsPalettedRasterRenderer¶
Bases:
QgsRasterRenderer
Renderer for paletted raster images.
QgsPalettedRasterRenderer(input:
QgsRasterInterface
, bandNumber: int, classes: Iterable[QgsPalettedRasterRenderer.Class]) Constructor for QgsPalettedRasterRenderer.Methods
- param visitor:
Returns the raster band used for rendering the raster.
- param bandNo:
Opens a color table file and returns corresponding paletted renderer class data.
Generates class data from a
raster
, for the specifiedbandNumber
.Converts a
string
containing a color table or class data to to paletted renderer class data.Converts classes to a string representation, using the .clr/gdal color table file format.
Returns a map of value to classes (colors) used by the renderer.
QgsPalettedRasterRenderer
cannot be copied.Converts a raster color
table
to paletted renderer class data.- param elem:
- param nodeLayer:
- rtype:
Qgis.RasterRendererFlags
Fill in histogram defaults if not specified
Fill in statistics defaults if not specified
Returns optional category label
- rtype:
List[Tuple[str, QColor]]
Returns number of colors
Returns the color for the renderer to use to represent nodata pixels.
Set category label
Set the source color
ramp
.Gets the source color ramp
- param doc:
- rtype:
List[int]
- param doc:
- class Class(value: float, color: QColor | Qt.GlobalColor | QGradient = QColor(), label: str = '')¶
Bases:
sip.wrapper
Constructor for Class
QgsPalettedRasterRenderer.Class(QgsPalettedRasterRenderer.Class)
- color¶
- label¶
- value¶
- accept(self, visitor: QgsStyleEntityVisitorInterface) bool ¶
- Parameters:
visitor (QgsStyleEntityVisitorInterface) –
- Return type:
bool
- band(self) int ¶
Returns the raster band used for rendering the raster.
New in version 3.0.
- 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:
- classDataFromFile(path: str) List[QgsPalettedRasterRenderer.Class] ¶
Opens a color table file and returns corresponding paletted renderer class data.
See also
New in version 3.0.
- Parameters:
path (str) –
- Return type:
- classDataFromRaster(raster: QgsRasterInterface, bandNumber: int, ramp: QgsColorRamp = None, feedback: QgsRasterBlockFeedback = None) List[QgsPalettedRasterRenderer.Class] ¶
Generates class data from a
raster
, for the specifiedbandNumber
. An optional colorramp
can be specified to automatically assign colors from the ramp.New in version 3.0.
- Parameters:
raster (QgsRasterInterface) –
bandNumber (int) –
ramp (
QgsColorRamp
= None) –feedback (
QgsRasterBlockFeedback
= None) –
- Return type:
- classDataFromString(string: str) List[QgsPalettedRasterRenderer.Class] ¶
Converts a
string
containing a color table or class data to to paletted renderer class data.See also
See also
New in version 3.0.
- Parameters:
string (str) –
- Return type:
- classDataToString(classes: Iterable[QgsPalettedRasterRenderer.Class]) str ¶
Converts classes to a string representation, using the .clr/gdal color table file format.
See also
New in version 3.0.
- Parameters:
classes (Iterable[QgsPalettedRasterRenderer.Class]) –
- Return type:
str
- classes(self) List[QgsPalettedRasterRenderer.Class] ¶
Returns a map of value to classes (colors) used by the renderer.
- Return type:
- clone(self) QgsPalettedRasterRenderer ¶
QgsPalettedRasterRenderer
cannot be copied. Useclone()
instead.- Return type:
- colorTableToClassData(table: Iterable[QgsColorRampShader.ColorRampItem]) List[QgsPalettedRasterRenderer.Class] ¶
Converts a raster color
table
to paletted renderer class data.New in version 3.0.
- Parameters:
table (Iterable[QgsColorRampShader.ColorRampItem]) –
- Return type:
- create(elem: QDomElement, input: QgsRasterInterface) QgsRasterRenderer ¶
- Parameters:
elem (QDomElement) –
input (QgsRasterInterface) –
- Return type:
- createLegendNodes(self, nodeLayer: QgsLayerTreeLayer) List[QgsLayerTreeModelLegendNode] ¶
- Parameters:
nodeLayer (QgsLayerTreeLayer) –
- Return type:
- flags(self) Qgis.RasterRendererFlags ¶
- 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
- label(self, idx: float) str ¶
Returns optional category label
New in version 2.1.
- Parameters:
idx (float) –
- Return type:
str
- legendSymbologyItems(self) List[Tuple[str, QColor]] ¶
- Return type:
List[Tuple[str, QColor]]
- nColors(self) int ¶
Returns number of colors
- Return type:
int
- 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.
- setLabel(self, idx: float, label: str)¶
Set category label
New in version 2.1.
- Parameters:
idx (float) –
label (str) –
- setSourceColorRamp(self, ramp: QgsColorRamp)¶
Set the source color
ramp
. Ownership is transferred to the renderer.See also
New in version 3.0.
- Parameters:
ramp (QgsColorRamp) –
- sourceColorRamp(self) QgsColorRamp ¶
Gets the source color ramp
See also
New in version 3.0.
- Return type:
- toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any] = {})¶
- Parameters:
doc (QDomDocument) –
element (QDomElement) –
props (Dict[str) –
- usesBands(self) List[int] ¶
- Return type:
List[int]
- writeXml(self, doc: QDomDocument, parentElem: QDomElement)¶
- Parameters:
doc (QDomDocument) –
parentElem (QDomElement) –