Class: QgsLabelThinningSettings

Contains settings related to how the label engine removes candidate label positions and reduces the number of displayed labels.

Added in version 3.12.

Methods

allowDuplicateRemoval

Returns whether duplicate label removal is permitted for this layer.

labelMarginDistance

Returns the minimum distance to other labels (i.e. the minimum space/margin around labels).

labelMarginDistanceMapUnitScale

Returns the map unit scale for the minimum distance to other labels.

labelMarginDistanceUnit

Returns the units for the minimum distance to other labels.

limitNumberOfLabelsEnabled

Returns True if the number of labels drawn for the layer should be limited.

maximumNumberLabels

Returns the maximum number of labels which should be drawn for this layer.

minimumDistanceToDuplicate

Returns the minimum distance to labels with duplicate text.

minimumDistanceToDuplicateMapUnitScale

Returns the map unit scale for the minimum distance to labels with duplicate text.

minimumDistanceToDuplicateUnit

Returns the units for the minimum distance to labels with duplicate text.

minimumFeatureSize

Returns the minimum feature size (in millimeters) for a feature to be labelled.

setAllowDuplicateRemoval

Sets whether duplicate label removal is permitted for this layer.

setLabelMarginDistance

Sets the minimum distance to other labels (i.e. the minimum space/margin around labels).

setLabelMarginDistanceMapUnitScale

Sets the map unit scale for the minimum distance to other labels.

setLabelMarginDistanceUnit

Sets the unit for the minimum distance to other labels.

setLimitNumberLabelsEnabled

Sets whether the the number of labels drawn for the layer should be limited.

setMaximumNumberLabels

Sets the maximum number of labels which should be drawn for this layer.

setMinimumDistanceToDuplicate

Sets the minimum distance to labels with duplicate text.

setMinimumDistanceToDuplicateMapUnitScale

Sets the map unit scale for the minimum distance to labels with duplicate text.

setMinimumDistanceToDuplicateUnit

Sets the unit for the minimum distance to labels with duplicate text.

setMinimumFeatureSize

Sets the minimum feature size (in millimeters) for a feature to be labelled.

updateDataDefinedProperties

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

class qgis.core.QgsLabelThinningSettings[source]

Bases: object

allowDuplicateRemoval(self) bool[source]

Returns whether duplicate label removal is permitted for this layer.

Added in version 3.44.

Return type:

bool

labelMarginDistance(self) float[source]

Returns the minimum distance to other labels (i.e. the minimum space/margin around labels).

Units are specified through labelMarginDistanceUnit().

Added in version 3.44.

Return type:

float

labelMarginDistanceMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the minimum distance to other labels.

Added in version 3.44.

Return type:

QgsMapUnitScale

labelMarginDistanceUnit(self) Qgis.RenderUnit[source]

Returns the units for the minimum distance to other labels.

Added in version 3.44.

Return type:

Qgis.RenderUnit

limitNumberOfLabelsEnabled(self) bool[source]

Returns True if the number of labels drawn for the layer should be limited.

Return type:

bool

maximumNumberLabels(self) int[source]

Returns the maximum number of labels which should be drawn for this layer. This only has an effect if limitNumberOfLabelsEnabled() is True.

Return type:

int

minimumDistanceToDuplicate(self) float[source]

Returns the minimum distance to labels with duplicate text.

Units are specified through minimumDistanceToDuplicateUnit().

Note

This setting is only respected if allowDuplicateRemoval() is True.

Added in version 3.44.

Return type:

float

minimumDistanceToDuplicateMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the minimum distance to labels with duplicate text.

Note

This setting is only respected if allowDuplicateRemoval() is True.

Added in version 3.44.

Return type:

QgsMapUnitScale

minimumDistanceToDuplicateUnit(self) Qgis.RenderUnit[source]

Returns the units for the minimum distance to labels with duplicate text.

Note

This setting is only respected if allowDuplicateRemoval() is True.

Added in version 3.44.

Return type:

Qgis.RenderUnit

minimumFeatureSize(self) float[source]

Returns the minimum feature size (in millimeters) for a feature to be labelled.

Return type:

float

setAllowDuplicateRemoval(self, allow: bool)[source]

Sets whether duplicate label removal is permitted for this layer.

Added in version 3.44.

Parameters:

allow (bool)

setLabelMarginDistance(self, distance: float)[source]

Sets the minimum distance to other labels (i.e. the minimum space/margin around labels).

Units are specified through setLabelMarginDistanceUnit().

Added in version 3.44.

Parameters:

distance (float)

setLabelMarginDistanceMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the minimum distance to other labels.

Added in version 3.44.

Parameters:

scale (QgsMapUnitScale)

setLabelMarginDistanceUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the minimum distance to other labels.

Added in version 3.44.

Parameters:

unit (Qgis.RenderUnit)

setLimitNumberLabelsEnabled(self, enabled: bool)[source]

Sets whether the the number of labels drawn for the layer should be limited.

Parameters:

enabled (bool)

setMaximumNumberLabels(self, number: int)[source]

Sets the maximum number of labels which should be drawn for this layer. This only has an effect if limitNumberOfLabelsEnabled() is True.

Parameters:

number (int)

setMinimumDistanceToDuplicate(self, distance: float)[source]

Sets the minimum distance to labels with duplicate text.

Units are specified through setMinimumDistanceToDuplicateUnit().

Note

This setting is only respected if allowDuplicateRemoval() is True.

Added in version 3.44.

Parameters:

distance (float)

setMinimumDistanceToDuplicateMapUnitScale(self, scale: QgsMapUnitScale)[source]

Sets the map unit scale for the minimum distance to labels with duplicate text.

Note

This setting is only respected if allowDuplicateRemoval() is True.

Added in version 3.44.

Parameters:

scale (QgsMapUnitScale)

setMinimumDistanceToDuplicateUnit(self, unit: Qgis.RenderUnit)[source]

Sets the unit for the minimum distance to labels with duplicate text.

Note

This setting is only respected if allowDuplicateRemoval() is True.

Added in version 3.44.

Parameters:

unit (Qgis.RenderUnit)

setMinimumFeatureSize(self, size: float)[source]

Sets the minimum feature size (in millimeters) for a feature to be labelled.

Parameters:

size (float)

updateDataDefinedProperties(self, properties: QgsPropertyCollection, context: QgsExpressionContext)[source]

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

Parameters: