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
Returns the classification mode
Classify color ramp shader
Classify color ramp shader
Returns whether the shader will clip values which are out of range.
Returns the custom colormap.
Returns the color ramp type.
Returns the color ramp type as a string.
Whether the color ramp contains any items
Reads configuration from the given DOM element
Sets classification mode
Sets whether the shader should not render values out of range.
Sets the color ramp type
Set the source color ramp.
Generates and new RGB value based on one input value
Gets the source color ramp
Writes configuration to a new DOM element
Signals
Attributes
-
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
-
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
-
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.
See also
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¶ Gets the source color ramp
See also
New in version 3.0.
-
writeXml
(self, doc: QDomDocument) → QDomElement¶ Writes configuration to a new DOM element
New in version 3.4.