Class: QgsLabelObstacleSettings

class qgis.core.QgsLabelObstacleSettings

Bases: sip.wrapper

Contains settings related to how the label engine treats features as obstacles

Methods

factor

Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, > 1.0 less likely to be covered

isObstacle

Returns True if the features are obstacles to labels of other layers.

obstacleGeometry

Returns the label’s obstacle geometry, if different to the feature geometry.

setFactor

Sets the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, > 1.0 less likely to be covered

setIsObstacle

Sets whether features are obstacles to labels of other layers.

setObstacleGeometry

Sets the label’s obstacle geometry, if different to the feature geometry.

setType

Controls how features act as obstacles for labels.

type

Returns how features act as obstacles for labels.

updateDataDefinedProperties

Updates the obstacle settings to respect any data defined properties set within the specified properties collection.

Attributes

PolygonBoundary

PolygonInterior

PolygonWhole

class ObstacleType

Bases: int

PolygonBoundary = 1
PolygonInterior = 0
PolygonWhole = 2
factor(self) → float

Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, > 1.0 less likely to be covered

See also

setFactor()

See also

isObstacle()

See also

type()

Return type

float

isObstacle(self) → bool

Returns True if the features are obstacles to labels of other layers.

See also

setIsObstacle()

See also

factor()

See also

type()

Return type

bool

obstacleGeometry(self) → QgsGeometry

Returns the label’s obstacle geometry, if different to the feature geometry.

Return type

QgsGeometry

setFactor(self, factor: float)

Sets the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, > 1.0 less likely to be covered

See also

factor()

See also

isObstacle()

See also

type()

Parameters

factor (float) –

setIsObstacle(self, isObstacle: bool)

Sets whether features are obstacles to labels of other layers.

See also

isObstacle()

See also

factor()

See also

type()

Parameters

isObstacle (bool) –

setObstacleGeometry(self, obstacleGeom: QgsGeometry)

Sets the label’s obstacle geometry, if different to the feature geometry. This can be used to override the shape of the feature for obstacle detection, e.g., to buffer around a point geometry to prevent labels being placed too close to the point itself. It not set, the feature’s geometry is used for obstacle detection.

Parameters

obstacleGeom (QgsGeometry) –

setType(self, type: QgsLabelObstacleSettings.ObstacleType)

Controls how features act as obstacles for labels.

See also

type()

See also

isObstacle()

See also

factor()

Parameters

type (QgsLabelObstacleSettings.ObstacleType) –

type(self) → QgsLabelObstacleSettings.ObstacleType

Returns how features act as obstacles for labels.

See also

setType()

See also

isObstacle()

See also

factor()

Return type

QgsLabelObstacleSettings.ObstacleType

updateDataDefinedProperties(self, properties: QgsPropertyCollection, context: QgsExpressionContext)

Updates the obstacle settings to respect any data defined properties set within the specified properties collection.

Parameters