Class: QgsSizeScaleTransformer

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

Class Hierarchy

Inheritance diagram of qgis.core.QgsSizeScaleTransformer

Base classes

QgsPropertyTransformer

Abstract base class for objects which transform the calculated value of a property.

class qgis.core.QgsSizeScaleTransformer[source]

Bases: QgsPropertyTransformer

__init__(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 (QgsSizeScaleTransformer.ScaleType = QgsSizeScaleTransformer.Linear) – scaling type

  • minValue (float = 0) – minimum expected value

  • maxValue (float = 1) – maximum expected value

  • minSize (float = 0) – minimum size to return

  • maxSize (float = 1) – maximum size to return

  • nullSize (float = 0) – size to return for null values

  • exponent (float = 1) – exponent for Exponential scaling method

__init__(a0: QgsSizeScaleTransformer)
Parameters:

a0 (QgsSizeScaleTransformer)

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

Bases: int

exponent(self) float[source]

Returns the exponent for an exponential expression.

See also

setExponent()

See also

type()

Return type:

float

static fromExpression(expression: str | None)[source]

Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.

Parameters:

expression (Optional[str]) -> (Optional[QgsSizeScaleTransformer]) – expression to parse

Returns:

  • corresponding QgsSizeScaleTransformer, or None if expression could not be parsed to a size scale transformer.

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

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

maxSize(self) float[source]

Returns the maximum calculated size.

See also

minSize()

Return type:

float

minSize(self) float[source]

Returns the minimum calculated size.

See also

setMinSize()

See also

maxSize()

Return type:

float

nullSize(self) float[source]

Returns the size value when an expression evaluates to NULL.

See also

setNullSize()

Return type:

float

setExponent(self, exponent: float)[source]

Sets the exponent for an exponential expression.

Parameters:

exponent (float) – exponent

See also

exponent()

setMaxSize(self, size: float)[source]

Sets the maximum calculated size.

Parameters:

size (float) – maximum size

See also

maxSize()

See also

setMinSize()

setMinSize(self, size: float)[source]

Sets the minimum calculated size.

Parameters:

size (float) – minimum size

See also

minSize()

See also

setMaxSize()

setNullSize(self, size: float)[source]

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

Parameters:

size (float) – null size

See also

nullSize()

setType(self, type: QgsSizeScaleTransformer.ScaleType)[source]

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[source]

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

type(self) QgsSizeScaleTransformer.ScaleType[source]

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

See also

setType()

Return type:

QgsSizeScaleTransformer.ScaleType