Class: QgsColorRampShader¶
- class qgis.core.QgsColorRampShader¶
Bases:
QgsRasterShaderFunction
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QgsColorRampShader(minimumValue: float = 0, maximumValue: float = 255, colorRamp:
QgsColorRamp
= None, type: QgsColorRampShader.Type = QgsColorRampShader.Interpolated, classificationMode: QgsColorRampShader.ClassificationMode = QgsColorRampShader.Continuous) 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.
QgsColorRampShader(other:
QgsColorRampShader
) Copy constructorMethods
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.
Creates a gradient color ramp from shader settings.
Whether the color ramp contains any items
Returns the color ramp shader legend settings.
- rtype:
List[Tuple[str, QColor]]
Reads configuration from the given DOM element
Sets classification mode
Sets whether the shader should not render values out of range.
- param list:
Sets the color ramp type
Sets the color ramp shader legend
settings
.Set the source color ramp.
Generates and new RGB value based on one input value
Returns the source color ramp.
Writes configuration to a new DOM element
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
- Return type:
- classifyColorRamp(self, classes: int = 0, band: int = -1, extent: QgsRectangle = QgsRectangle(), input: QgsRasterInterface = None)¶
Classify color ramp shader
- Parameters:
classes (int = 0) – number of classes
band (int = -1) – raster band used in classification (only used in quantile mode)
extent (
QgsRectangle
= QgsRectangle()) – extent used in classification (only used in quantile mode)input (
QgsRasterInterface
= None) – 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 (int = -1) – raster band used in classification (quantile mode only)
extent (
QgsRectangle
= QgsRectangle()) – extent used in classification (quantile mode only)input (
QgsRasterInterface
= None) – 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
- Return type:
bool
- colorRampItemList(self) List[QgsColorRampShader.ColorRampItem] ¶
Returns the custom colormap.
- Return type:
- colorRampType(self) QgsColorRampShader.Type ¶
Returns the color ramp type.
- Return type:
- colorRampTypeAsQString(self) str ¶
Returns the color ramp type as a string.
- Return type:
str
- createColorRamp(self) QgsColorRamp ¶
Creates a gradient color ramp from shader settings.
New in version 3.18.
- Return type:
- isEmpty(self) bool ¶
Whether the color ramp contains any items
New in version 3.4.
- Return type:
bool
- legendSettings(self) QgsColorRampLegendNodeSettings ¶
Returns the color ramp shader legend settings.
See also
New in version 3.18.
- Return type:
- legendSymbologyItems(self) List[Tuple[str, QColor]] ¶
- Return type:
List[Tuple[str, QColor]]
- readXml(self, elem: QDomElement, context: QgsReadWriteContext = QgsReadWriteContext())¶
Reads configuration from the given DOM element
New in version 3.4.
- Parameters:
elem (QDomElement) –
context (
QgsReadWriteContext
= QgsReadWriteContext()) –
- setClassificationMode(self, classificationMode: QgsColorRampShader.ClassificationMode)¶
Sets classification mode
- Parameters:
classificationMode (QgsColorRampShader.ClassificationMode) –
- setClip(self, clip: bool)¶
Sets whether the shader should not render values out of range.
- Parameters:
clip (bool) – set to
True
to clip values which are out of range.
See also
- setColorRampItemList(self, list: Iterable[QgsColorRampShader.ColorRampItem])¶
- Parameters:
list (Iterable[QgsColorRampShader.ColorRampItem]) –
- setColorRampType(self, colorRampType: QgsColorRampShader.Type)¶
Sets the color ramp type
setColorRampType(self, type: str) Sets the color ramp type
- Parameters:
colorRampType (QgsColorRampShader.Type) –
- setLegendSettings(self, settings: QgsColorRampLegendNodeSettings)¶
Sets the color ramp shader legend
settings
.Ownership of
settings
is transferred.See also
New in version 3.18.
- Parameters:
settings (QgsColorRampLegendNodeSettings) –
- setSourceColorRamp(self, colorramp: QgsColorRamp)¶
Set the source color ramp. Ownership is transferred to the shader.
See also
New in version 3.0.
- Parameters:
colorramp (QgsColorRamp) –
- 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
- Parameters:
value (float) –
- Return type:
Tuple[bool, int, int, int, int]
- sourceColorRamp(self) QgsColorRamp ¶
Returns the source color ramp.
See also
New in version 3.0.
- Return type:
- writeXml(self, doc: QDomDocument, context: QgsReadWriteContext = QgsReadWriteContext()) QDomElement ¶
Writes configuration to a new DOM element
New in version 3.4.
- Parameters:
doc (QDomDocument) –
context (
QgsReadWriteContext
= QgsReadWriteContext()) –
- Return type:
QDomElement