Class: QgsSizeScaleTransformer

class qgis.core.QgsSizeScaleTransformer

Bases: QgsPropertyTransformer

QgsPropertyTransformer subclass for scaling a value into a size according to various scaling methods.

New in version 3.0.

QgsSizeScaleTransformer(type: QgsSizeScaleTransformer.ScaleType = QgsSizeScaleTransformer.Linear, minValue: float = 0, maxValue: float = 1, minSize: float = 0, maxSize: float = 1, nullSize: float = 0, exponent: float = 1) Constructor for QgsSizeScaleTransformer.

Parameters
  • type – scaling type

  • minValue – minimum expected value

  • maxValue – maximum expected value

  • minSize – minimum size to return

  • maxSize – maximum size to return

  • nullSize – size to return for null values

  • exponent – exponent for Exponential scaling method

QgsSizeScaleTransformer(QgsSizeScaleTransformer)

Methods

clone

rtype

QgsSizeScaleTransformer

exponent

Returns the exponent for an exponential expression.

fromExpression

Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.

loadVariant

param definition

maxSize

Returns the maximum calculated size.

minSize

Returns the minimum calculated size.

nullSize

Returns the size value when an expression evaluates to NULL.

setExponent

Sets the exponent for an exponential expression.

setMaxSize

Sets the maximum calculated size.

setMinSize

Sets the minimum calculated size.

setNullSize

Sets the size value for when an expression evaluates to NULL.

setType

Sets the size transformer's scaling type (the method used to calculate the size from a value).

size

Calculates the size corresponding to a specific value.

toExpression

param baseExpression

toVariant

rtype

Any

transform

param context

transformNumeric

Applies base class numeric transformations.

transformerType

rtype

QgsPropertyTransformer.Type

type

Returns the size transformer's scaling type (the method used to calculate the size from a value).

Attributes

Area

Exponential

Flannery

Linear

Area = 1
Exponential = 3
Flannery = 2
Linear = 0
class ScaleType

Bases: int

clone(self) QgsSizeScaleTransformer
Return type

QgsSizeScaleTransformer

exponent(self) float

Returns the exponent for an exponential expression.

See also

setExponent()

See also

type()

Return type

float

fromExpression(expression: str) Tuple[QgsSizeScaleTransformer, str, str]

Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.

Parameters

expression (str) – expression to parse

Return type

Tuple[QgsSizeScaleTransformer, str, str]

Returns

  • corresponding QgsSizeScaleTransformer, or None if expression could not

  • 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.

be parsed to a size scale transformer.

loadVariant(self, definition: Any) bool
Parameters

definition (Any) –

Return type

bool

maxSize(self) float

Returns the maximum calculated size.

See also

minSize()

Return type

float

minSize(self) float

Returns the minimum calculated size.

See also

setMinSize()

See also

maxSize()

Return type

float

nullSize(self) float

Returns the size value when an expression evaluates to NULL.

See also

setNullSize()

Return type

float

setExponent(self, exponent: float)

Sets the exponent for an exponential expression.

Parameters

exponent (float) – exponent

See also

exponent()

setMaxSize(self, size: float)

Sets the maximum calculated size.

Parameters

size (float) – maximum size

See also

maxSize()

See also

setMinSize()

setMinSize(self, size: float)

Sets the minimum calculated size.

Parameters

size (float) – minimum size

See also

minSize()

See also

setMaxSize()

setNullSize(self, size: float)

Sets the size value for when an expression evaluates to NULL.

Parameters

size (float) – null size

See also

nullSize()

setType(self, type: QgsSizeScaleTransformer.ScaleType)

Sets the size transformer’s scaling type (the method used to calculate the size from a value).

Parameters

type (QgsSizeScaleTransformer.ScaleType) – scale type

See also

type()

size(self, value: float) float

Calculates the size corresponding to a specific value.

Parameters

value (float) – value to calculate size for

Return type

float

Returns

calculated size using size scale transformer’s parameters and type

toExpression(self, baseExpression: str) str
Parameters

baseExpression (str) –

Return type

str

toVariant(self) Any
Return type

Any

transform(self, context: QgsExpressionContext, value: Any) Any
Parameters
Return type

Any

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
Return type

QgsPropertyTransformer.Type

type(self) QgsSizeScaleTransformer.ScaleType

Returns the size transformer’s scaling type (the method used to calculate the size from a value).

See also

setType()

Return type

QgsSizeScaleTransformer.ScaleType