Class: QgsColorRampShader¶
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Class Hierarchy¶
Base classes¶
The raster shade function applies a shader to a pixel at render time - typically used to render grayscale images as false color. |
Enums
alias of |
|
alias of |
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 color map. |
|
Returns the color ramp interpolation method. |
|
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. |
|
Reads configuration from the given DOM element |
|
Sets the classification mode. |
|
Sets whether the shader should not render values out of range. |
|
Sets the color ramp interpolation method. |
|
Sets the color ramp shader legend settings. |
|
Set the source color ramp. |
|
Returns the source color ramp. |
|
Writes configuration to a new DOM element |
- class qgis.core.QgsColorRampShader[source]¶
Bases:
QgsRasterShaderFunction
- __init__(minimumValue: float = 0, maximumValue: float = 255, colorRamp: QgsColorRamp | None = None, type: Qgis.ShaderInterpolationMethod = Qgis.ShaderInterpolationMethod.Linear, classificationMode: Qgis.ShaderClassificationMethod = Qgis.ShaderClassificationMethod.Continuous)
Creates a new color ramp shader.
- Parameters:
minimumValue (float = 0) – minimum value for the raster shader
maximumValue (float = 255) – maximum value for the raster shader
type (Qgis.ShaderInterpolationMethod = Qgis.ShaderInterpolationMethod.Linear) – interpolation type used
classificationMode (Qgis.ShaderClassificationMethod = Qgis.ShaderClassificationMethod.Continuous) – method used to classify the color ramp shader
colorRamp (Optional[QgsColorRamp] = None) – vector color ramp used to classify the color ramp shader. Ownership is transferred to the shader.
- __init__(other: QgsColorRampShader)
- Parameters:
other (QgsColorRampShader)
- ClassificationMode¶
alias of
ShaderClassificationMethod
- class ColorRampItem¶
Bases:
object
QgsColorRampShader.ColorRampItem(val: float, col: Union[QColor, Qt.GlobalColor], lbl: Optional[str] = ‘’) convenience constructor
QgsColorRampShader.ColorRampItem(a0: QgsColorRampShader.ColorRampItem)
- color¶
- label¶
- value¶
- Type¶
alias of
ShaderInterpolationMethod
- classificationMode(self) Qgis.ShaderClassificationMethod [source]¶
Returns the classification mode.
See also
- Return type:
- classifyColorRamp(self, classes: int = 0, band: int = -1, extent: QgsRectangle = QgsRectangle(), input: QgsRasterInterface | None = None)[source]¶
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 (Optional[QgsRasterInterface] = None) – raster input used in classification (only used in quantile mode)
- classifyColorRampV2(self, band: int = -1, extent: QgsRectangle = QgsRectangle(), input: QgsRasterInterface | None = 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 (Optional[QgsRasterInterface] = None) – raster input used in classification (quantile mode only)
- clip(self) bool [source]¶
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 color map.
See also
- Return type:
- colorRampType(self) Qgis.ShaderInterpolationMethod [source]¶
Returns the color ramp interpolation method.
See also
- Return type:
- colorRampTypeAsQString(self) str [source]¶
Returns the color ramp type as a string.
- Return type:
str
- createColorRamp(self) QgsColorRamp | None [source]¶
Creates a gradient color ramp from shader settings.
Added in version 3.18.
- Return type:
Optional[QgsColorRamp]
- isEmpty(self) bool [source]¶
Whether the color ramp contains any items
Added in version 3.4.
- Return type:
bool
- legendSettings(self) QgsColorRampLegendNodeSettings | None [source]¶
Returns the color ramp shader legend settings.
See also
Added in version 3.18.
- Return type:
Optional[QgsColorRampLegendNodeSettings]
- readXml(self, elem: QDomElement, context: QgsReadWriteContext = QgsReadWriteContext())[source]¶
Reads configuration from the given DOM element
Added in version 3.4.
- Parameters:
elem (QDomElement)
context (
QgsReadWriteContext
= QgsReadWriteContext())
- setClassificationMode(self, classificationMode: Qgis.ShaderClassificationMethod)[source]¶
Sets the classification mode.
See also
- Parameters:
classificationMode (Qgis.ShaderClassificationMethod)
- setClip(self, clip: bool)[source]¶
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])[source]¶
- Parameters:
list (Iterable[QgsColorRampShader.ColorRampItem])
- setColorRampType(self, colorRampType: Qgis.ShaderInterpolationMethod)[source]¶
Sets the color ramp interpolation method.
See also
- Parameters:
colorRampType (Qgis.ShaderInterpolationMethod)
- setColorRampType(self, type: str | None)[source]
Sets the color ramp type
- Parameters:
type (Optional[str])
- setLegendSettings(self, settings: QgsColorRampLegendNodeSettings | None)[source]¶
Sets the color ramp shader legend
settings
.Ownership of
settings
is transferred.See also
Added in version 3.18.
- Parameters:
settings (Optional[QgsColorRampLegendNodeSettings])
- setSourceColorRamp(self, colorramp: QgsColorRamp | None)[source]¶
Set the source color ramp. Ownership is transferred to the shader.
See also
- Parameters:
colorramp (Optional[QgsColorRamp])
- sourceColorRamp(self) QgsColorRamp | None [source]¶
Returns the source color ramp.
See also
- Return type:
Optional[QgsColorRamp]
- writeXml(self, doc: QDomDocument, context: QgsReadWriteContext = QgsReadWriteContext()) QDomElement [source]¶
Writes configuration to a new DOM element
Added in version 3.4.
- Parameters:
doc (QDomDocument)
context (
QgsReadWriteContext
= QgsReadWriteContext())
- Return type:
QDomElement