Class: QgsPalettedRasterRenderer¶
Renderer for paletted raster images.
Class Hierarchy¶
Base classes¶
Raster renderer pipe that applies colors to a raster. |
|
Base class for processing filters like renderers, reprojector, resampler etc. |
Methods
Returns the raster band used for rendering the raster. |
|
Returns a map of value to classes (colors) used by the renderer. |
|
Returns optional category label |
|
Returns a map of multi value to classes (colors) used by the renderer. |
|
Returns number of colors |
|
Set category label |
|
Sets the multi value classes to setMultiValueClasses. |
|
Set the source color ramp. |
|
Gets the source color ramp |
Static Methods
Opens a color table file and returns corresponding paletted renderer class data. |
|
Generates class data from a raster, for the specified bandNumber. |
|
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. |
|
Converts a raster color table to paletted renderer class data. |
|
Reads and returns classes from the Raster Attribute Table attributeTable, optionally classifying the attribute table by classificationColumn and setting the colors from ramp. |
- class qgis.core.QgsPalettedRasterRenderer[source]¶
Bases:
QgsRasterRenderer
- __init__(input: QgsRasterInterface | None, bandNumber: int, classes: Iterable[QgsPalettedRasterRenderer.Class])
Constructor for QgsPalettedRasterRenderer.
- Parameters:
input (Optional[QgsRasterInterface])
bandNumber (int)
classes (Iterable[QgsPalettedRasterRenderer.Class])
- class Class¶
Bases:
object
Properties of a single value class
- color: QColor¶
Color to render value
- label: str¶
Label for value
- value: float¶
Value
- class MultiValueClass[source]¶
Bases:
object
Properties of a multi value class: a class that contains multiple values.
Added in version 3.30.
QgsPalettedRasterRenderer.MultiValueClass(values: Iterable[Any], color: Union[QColor, Qt.GlobalColor] = QColor(), label: Optional[str] = ‘’) Constructor for MultiValueClass from a list of values
QgsPalettedRasterRenderer.MultiValueClass(a0: QgsPalettedRasterRenderer.MultiValueClass)
- color: QColor¶
Color to render values
- label: str¶
Label for values
- values: List[object]¶
Values
- band(self) int [source]¶
Returns the raster band used for rendering the raster.
Deprecated since version 3.38: Use
inputBand()
instead.- Return type:
int
- static classDataFromFile(path: str | None) List[QgsPalettedRasterRenderer.Class] [source]¶
Opens a color table file and returns corresponding paletted renderer class data.
See also
- Parameters:
path (Optional[str])
- Return type:
- static classDataFromRaster(raster: QgsRasterInterface | None, bandNumber: int, ramp: QgsColorRamp | None = None, feedback: QgsRasterBlockFeedback | None = None) List[QgsPalettedRasterRenderer.Class] [source]¶
Generates class data from a
raster
, for the specifiedbandNumber
. An optional colorramp
can be specified to automatically assign colors from the ramp.- Parameters:
raster (Optional[QgsRasterInterface])
bandNumber (int)
ramp (Optional[QgsColorRamp] = None)
feedback (Optional[QgsRasterBlockFeedback] = None)
- Return type:
- static classDataFromString(string: str | None) List[QgsPalettedRasterRenderer.Class] [source]¶
Converts a
string
containing a color table or class data to to paletted renderer class data.See also
See also
- Parameters:
string (Optional[str])
- Return type:
- static classDataToString(classes: Iterable[QgsPalettedRasterRenderer.Class]) str [source]¶
Converts classes to a string representation, using the .clr/gdal color table file format.
See also
- Parameters:
classes (Iterable[QgsPalettedRasterRenderer.Class])
- Return type:
str
- classes(self) List[QgsPalettedRasterRenderer.Class] [source]¶
Returns a map of value to classes (colors) used by the renderer.
- Return type:
- static colorTableToClassData(table: Iterable[QgsColorRampShader.ColorRampItem]) List[QgsPalettedRasterRenderer.Class] [source]¶
Converts a raster color
table
to paletted renderer class data.- Parameters:
table (Iterable[QgsColorRampShader.ColorRampItem])
- Return type:
- static create(elem: QDomElement, input: QgsRasterInterface | None) QgsRasterRenderer | None [source]¶
- Parameters:
elem (QDomElement)
input (Optional[QgsRasterInterface])
- Return type:
Optional[QgsRasterRenderer]
- label(self, idx: float) str [source]¶
Returns optional category label
- Parameters:
idx (float)
- Return type:
str
- multiValueClasses(self) List[QgsPalettedRasterRenderer.MultiValueClass] [source]¶
Returns a map of multi value to classes (colors) used by the renderer.
Added in version 3.30.
- Return type:
- static rasterAttributeTableToClassData(attributeTable: QgsRasterAttributeTable | None, classificationColumn: int = -1, ramp: QgsColorRamp | None = None) List[QgsPalettedRasterRenderer.MultiValueClass] [source]¶
Reads and returns classes from the Raster Attribute Table
attributeTable
, optionally classifying the attribute table byclassificationColumn
and setting the colors fromramp
. The default value of -1 for the classificationColumn uses the first available value column.Note
The method will return an empty list of classes in case the Raster Attribute Table is not thematic.
Added in version 3.30.
- Parameters:
attributeTable (Optional[QgsRasterAttributeTable])
classificationColumn (int = -1)
ramp (Optional[QgsColorRamp] = None)
- Return type:
- setLabel(self, idx: float, label: str | None)[source]¶
Set category label
- Parameters:
idx (float)
label (Optional[str])
- setMultiValueClasses(self, classes: Iterable[QgsPalettedRasterRenderer.MultiValueClass])[source]¶
Sets the multi value classes to
setMultiValueClasses
.Added in version 3.30.
- Parameters:
classes (Iterable[QgsPalettedRasterRenderer.MultiValueClass])
- setSourceColorRamp(self, ramp: QgsColorRamp | None)[source]¶
Set the source color
ramp
. Ownership is transferred to the renderer.See also
- Parameters:
ramp (Optional[QgsColorRamp])
- sourceColorRamp(self) QgsColorRamp | None [source]¶
Gets the source color ramp
See also
- Return type:
Optional[QgsColorRamp]