Class: QgsPropertyTransformer

class qgis.core.QgsPropertyTransformer(minValue: float = 0, maxValue: float = 1)

Bases: sip.wrapper

Constructor for QgsPropertyTransformer

Parameters
  • minValue – minimum expected value from source property

  • maxValue – maximum expected value from source property

QgsPropertyTransformer(other: QgsPropertyTransformer) Copy constructor.

Abstract base class for objects which transform the calculated value of a property. Possible uses include transformers which map a value into a scaled size or color from a gradient.

New in version 3.0: Enums

Methods

clone

Returns a clone of the transformer.

create

Factory method for creating a new property transformer of the specified type.

curveTransform

Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.

fromExpression

Attempts to parse an expression into a corresponding property transformer.

loadVariant

Loads this transformer from a QVariantMap, wrapped in a QVariant.

maxValue

Returns the maximum value expected by the transformer.

minValue

Returns the minimum value expected by the transformer.

setCurveTransform

Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses.

setMaxValue

Sets the maximum value expected by the transformer.

setMinValue

Sets the minimum value expected by the transformer.

toExpression

Converts the transformer to a QGIS expression string.

toVariant

Saves this transformer to a QVariantMap, wrapped in a QVariant.

transform

Calculates the transform of a value.

transformNumeric

Applies base class numeric transformations.

transformerType

Returns the transformer type.

Signals

Attributes

ColorRampTransformer

GenericNumericTransformer

SizeScaleTransformer

ColorRampTransformer = 2
GenericNumericTransformer = 0
SizeScaleTransformer = 1
class Type

Bases: int

clone(self) → QgsPropertyTransformer

Returns a clone of the transformer.

create(type: QgsPropertyTransformer.Type) → QgsPropertyTransformer

Factory method for creating a new property transformer of the specified type.

Parameters

type – transformer type to create

curveTransform(self) → QgsCurveTransform

Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.

fromExpression(expression: str) → Tuple[QgsPropertyTransformer, str, str]

Attempts to parse an expression into a corresponding property transformer.

Parameters
  • expression – expression to parse

  • baseExpression – will be set to the component of the source expression which is used to calculate the input to the property transformer. This will be set to an empty string if a field reference is the transformer input.

  • fieldName – will be set to a field name which is used to calculate the input to the property transformer. This will be set to an empty string if an expression is the transformer input.

Returns

corresponding property transformer, or None if expression could not be parsed to a transformer.

loadVariant(self, transformer: Any) → bool

Loads this transformer from a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.readVariant to read it from an XML document.

See also

toVariant()

maxValue(self) → float

Returns the maximum value expected by the transformer.

See also

minValue()

See also

setMaxValue()

minValue(self) → float

Returns the minimum value expected by the transformer.

See also

maxValue()

See also

setMinValue()

setCurveTransform(self, transform: QgsCurveTransform)

Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses. Ownership of transform is transferred to the property transformer.

See also

curveTransform()

setMaxValue(self, max: float)

Sets the maximum value expected by the transformer.

Parameters

max – maximum value

See also

setMinValue()

See also

maxValue()

setMinValue(self, min: float)

Sets the minimum value expected by the transformer.

Parameters

min – minimum value

See also

setMaxValue()

See also

minValue()

toExpression(self, baseExpression: str) → str

Converts the transformer to a QGIS expression string. The baseExpression string consists of a sub-expression reflecting the parent property’s state.

toVariant(self) → Any

Saves this transformer to a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.writeVariant to save it to an XML document.

See also

loadVariant()

transform(self, context: QgsExpressionContext, value: Any) → Any

Calculates the transform of a value. Derived classes must implement this to perform their transformations on input values

Parameters
  • context – expression context

  • value – input value to transform

transformNumeric(self, input: float) → float

Applies base class numeric transformations. Derived classes should call this to transform an input numeric value before they apply any transform to the result. This applies any curve transforms which may exist on the transformer.

transformerType(self) → QgsPropertyTransformer.Type

Returns the transformer type.