Class: QgsLabelObstacleSettings¶
- class qgis.core.QgsLabelObstacleSettings¶
Bases:
sip.wrapper
Contains settings related to how the label engine treats features as obstacles
New in version 3.10.2:
Enums
Bases:
enum.IntEnum
Methods
Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, > 1.0 less likely to be covered
Returns
True
if the features are obstacles to labels of other layers.Returns the label's obstacle geometry, if different to the feature geometry.
Sets the obstacle
factor
, where 1.0 = default, < 1.0 more likely to be covered by labels, > 1.0 less likely to be coveredSets whether features are obstacles to labels of other layers.
Sets the label's obstacle geometry, if different to the feature geometry.
Controls how features act as obstacles for labels.
Returns how features act as obstacles for labels.
Updates the obstacle settings to respect any data defined properties set within the specified
properties
collection.- class ObstacleType(value)¶
Bases:
enum.IntEnum
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
PolygonInterior
: Avoid placing labels over interior of polygon (prefer placing labels totally outside or just slightly inside polygon)PolygonBoundary
: Avoid placing labels over boundary of polygon (prefer placing outside or completely inside polygon)PolygonWhole
: Avoid placing labels over ANY part of polygon. Where PolygonInterior will prefer to place labels with the smallest area of intersection between the label and the polygon, PolygonWhole will penalise any label which intersects with the polygon by an equal amount, so that placing labels over any part of the polygon is avoided
- 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
See also
See also
- Return type:
float
- isObstacle(self) bool ¶
Returns
True
if the features are obstacles to labels of other layers.See also
See also
See also
- Return type:
bool
- obstacleGeometry(self) QgsGeometry ¶
Returns the label’s obstacle geometry, if different to the feature geometry.
See also
- Return type:
- 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 coveredSee also
See also
See also
- Parameters:
factor (float) –
- setIsObstacle(self, isObstacle: bool)¶
Sets whether features are obstacles to labels of other layers.
See also
See also
See also
- 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.
See also
- Parameters:
obstacleGeom (QgsGeometry) –
- setType(self, type: QgsLabelObstacleSettings.ObstacleType)¶
Controls how features act as obstacles for labels.
See also
See also
See also
- Parameters:
- type(self) QgsLabelObstacleSettings.ObstacleType ¶
Returns how features act as obstacles for labels.
See also
See also
See also
- Return type:
- updateDataDefinedProperties(self, properties: QgsPropertyCollection, context: QgsExpressionContext)¶
Updates the obstacle settings to respect any data defined properties set within the specified
properties
collection.- Parameters:
properties (QgsPropertyCollection) –
context (QgsExpressionContext) –