Class: QgsColorRampShader

class qgis.core.QgsColorRampShader(minimumValue: float = 0, maximumValue: float = 255, colorRamp: QgsColorRamp = None, type: QgsColorRampShader.Type = QgsColorRampShader.Interpolated, classificationMode: QgsColorRampShader.ClassificationMode = QgsColorRampShader.Continuous)

Bases: qgis._core.QgsRasterShaderFunction

Creates a new color ramp shader.

Parameters
  • minimumValue – minimum value for the raster shader

  • maximumValue – maximum value for the raster shader

  • type – interpolation type used

  • classificationMode – method used to classify the color ramp shader

  • colorRamp – vector color ramp used to classify the color ramp shader. Ownership is transferred to the shader.

Returns

new QgsColorRampShader

QgsColorRampShader(other: QgsColorRampShader) Copy constructor

A ramp shader will color a raster pixel based on a list of values ranges in a ramp.

Enums

Methods

classificationMode

Returns the classification mode

classifyColorRamp

Classify color ramp shader

classifyColorRampV2

Classify color ramp shader

clip

Returns whether the shader will clip values which are out of range.

colorRampItemList

Returns the custom colormap.

colorRampType

Returns the color ramp type.

colorRampTypeAsQString

Returns the color ramp type as a string.

isEmpty

Whether the color ramp contains any items

legendSymbologyItems

readXml

Reads configuration from the given DOM element

setClassificationMode

Sets classification mode

setClip

Sets whether the shader should not render values out of range.

setColorRampItemList

setColorRampType

Sets the color ramp type

setSourceColorRamp

Set the source color ramp.

shade

Generates and new RGB value based on one input value

sourceColorRamp

Returns the source color ramp.

writeXml

Writes configuration to a new DOM element

Signals

Attributes

Continuous

Discrete

EqualInterval

Exact

Interpolated

Quantile

class ClassificationMode

Bases: int

class ColorRampItem

Bases: sip.wrapper

default constructor

QgsColorRampShader.ColorRampItem(val: float, col: Union[QColor, Qt.GlobalColor, QGradient], lbl: str = ‘’) convenience constructor

QgsColorRampShader.ColorRampItem(QgsColorRampShader.ColorRampItem)

color
label
value
Continuous = 1
Discrete = 1
EqualInterval = 2
Exact = 2
Interpolated = 0
Quantile = 3
class Type

Bases: int

classificationMode(self) → QgsColorRampShader.ClassificationMode

Returns the classification mode

classifyColorRamp(self, classes: int = 0, band: int = -1, extent: QgsRectangle = QgsRectangle(), input: QgsRasterInterface = None)

Classify color ramp shader

Parameters
  • classes – number of classes

  • band – raster band used in classification (only used in quantile mode)

  • extent – extent used in classification (only used in quantile mode)

  • input – raster input used in classification (only used in quantile mode)

classifyColorRampV2(self, band: int = -1, extent: QgsRectangle = QgsRectangle(), input: QgsRasterInterface = None)

Classify color ramp shader

Parameters
  • band – raster band used in classification (quantile mode only)

  • extent – extent used in classification (quantile mode only)

  • input – raster input used in classification (quantile mode only)

clip(self) → bool

Returns whether the shader will clip values which are out of range.

See also

setClip()

colorRampItemList(self) → object

Returns the custom colormap.

colorRampType(self) → QgsColorRampShader.Type

Returns the color ramp type.

colorRampTypeAsQString(self) → str

Returns the color ramp type as a string.

isEmpty(self) → bool

Whether the color ramp contains any items

New in version 3.4.

legendSymbologyItems(self) → List[Tuple[str, QColor]]
readXml(self, elem: QDomElement)

Reads configuration from the given DOM element

New in version 3.4.

setClassificationMode(self, classificationMode: QgsColorRampShader.ClassificationMode)

Sets classification mode

setClip(self, clip: bool)

Sets whether the shader should not render values out of range.

Parameters

clip – set to true to clip values which are out of range.

See also

clip()

setColorRampItemList(self, list: Iterable[QgsColorRampShader.ColorRampItem])
setColorRampType(self, colorRampType: QgsColorRampShader.Type)

Sets the color ramp type

setColorRampType(self, type: str) Sets the color ramp type

setSourceColorRamp(self, colorramp: QgsColorRamp)

Set the source color ramp. Ownership is transferred to the shader.

New in version 3.0.

shade(self, value: float) → Tuple[bool, int, int, int, int]

Generates and new RGB value based on one input value

shade(self, redValue: float, greenValue: float, blueValue: float, alphaValue: float) -> Tuple[bool, int, int, int, int] Generates and new RGB value based on original RGB value

sourceColorRamp(self) → QgsColorRamp

Returns the source color ramp.

New in version 3.0.

writeXml(self, doc: QDomDocument) → QDomElement

Writes configuration to a new DOM element

New in version 3.4.