Class: QgsSvgMarkerSymbolLayer

class qgis.core.QgsSvgMarkerSymbolLayer(path: str, size: float = DEFAULT_SVGMARKER_SIZE, angle: float = DEFAULT_SVGMARKER_ANGLE, scaleMethod: Qgis.ScaleMethod = DEFAULT_SCALE_METHOD)

Bases: QgsMarkerSymbolLayer

Constructs SVG marker symbol layer with picture from given absolute path to a SVG file

Methods

bounds

param point:

calculateAspectRatio

Calculates the marker aspect ratio between width and height.

clone

rtype:

QgsSvgMarkerSymbolLayer

copyDataDefinedProperties

Copies all data defined properties of this layer to another symbol layer.

copyPaintEffect

Copies paint effect of this layer to another symbol layer

create

Creates the symbol

createFromSld

param element:

defaultAspectRatio

Returns the default marker aspect ratio between width and height, 0 if not yet calculated.

fillColor

rtype:

QColor

fixedAspectRatio

Returns the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

installMasks

When rendering, install masks on context painter if recursive is True masks are installed recursively for all children symbol layers

layerType

rtype:

str

mapUnitScale

rtype:

QgsMapUnitScale

markerOffset

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

markerOffset2

markerOffsetWithWidthAndHeight

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

outputUnit

rtype:

Qgis.RenderUnit

parameters

Returns the dynamic SVG parameters

path

Returns the marker SVG path.

prepareExpressions

param context:

preservedAspectRatio

Returns the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0.

properties

rtype:

Dict[str, Any]

removeMasks

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

renderPoint

param point:

resolvePaths

Turns relative paths in properties map to absolute when reading and vice versa when writing.

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

setFillColor

param color:

setFixedAspectRatio

Set the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

setMapUnitScale

param scale:

setOutputUnit

param unit:

setParameters

Sets the dynamic SVG parameters

setPath

Set the marker SVG path.

setPreservedAspectRatio

Set preserved the marker aspect ratio between width and height.

setStrokeColor

param c:

setStrokeWidth

param w:

setStrokeWidthMapUnitScale

param scale:

setStrokeWidthUnit

Sets the units for the stroke width.

shouldRenderUsingSelectionColor

Returns True if the symbol layer should be rendered using the selection color from the render context.

startRender

param context:

stopRender

param context:

strokeColor

rtype:

QColor

strokeWidth

rtype:

float

strokeWidthMapUnitScale

rtype:

QgsMapUnitScale

strokeWidthUnit

Returns the units for the stroke width.

updateDefaultAspectRatio

Calculates the default marker aspect ratio between width and height.

usedAttributes

param context:

usesMapUnits

rtype:

bool

writeDxf

param e:

writeSldMarker

param doc:

bounds(self, point: QPointF | QPoint, context: QgsSymbolRenderContext) QRectF
Parameters:
Return type:

QRectF

calculateAspectRatio(self, context: QgsSymbolRenderContext, scaledSize: float) Tuple[float, bool]

Calculates the marker aspect ratio between width and height.

Parameters:
  • context (QgsSymbolRenderContext) – symbol render context

  • scaledSize (float) – size of symbol to render

  • hasDataDefinedAspectRatio – will be set to True if marker has data defined aspectRatio

Return type:

Tuple[float, bool]

clone(self) QgsSvgMarkerSymbolLayer
Return type:

QgsSvgMarkerSymbolLayer

copyDataDefinedProperties(self, destLayer: QgsSymbolLayer)

Copies all data defined properties of this layer to another symbol layer.

Parameters:

destLayer – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer)

Copies paint effect of this layer to another symbol layer

Parameters:

destLayer – destination layer

create(properties: Dict[str, Any] = {}) QgsSymbolLayer

Creates the symbol

Parameters:

properties (Dict[str) –

Return type:

QgsSymbolLayer

createFromSld(element: QDomElement) QgsSymbolLayer
Parameters:

element (QDomElement) –

Return type:

QgsSymbolLayer

defaultAspectRatio(self) float

Returns the default marker aspect ratio between width and height, 0 if not yet calculated.

Return type:

float

fillColor(self) QColor
Return type:

QColor

fixedAspectRatio(self) float

Returns the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

Return type:

float

installMasks(self, context: QgsRenderContext, recursive: bool)

When rendering, install masks on context painter if recursive is True masks are installed recursively for all children symbol layers

See also

prepareMasks()

See also

removeMasks()

New in version 3.30.

layerType(self) str
Return type:

str

mapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

markerOffset(self, context: QgsSymbolRenderContext) Tuple[float, float]

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context – symbol render context

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

markerOffset2(self, context: QgsSymbolRenderContext, width: float, height: float, widthUnit: Qgis.RenderUnit, heightUnit: Qgis.RenderUnit, widthMapUnitScale: QgsMapUnitScale, heightMapUnitScale: QgsMapUnitScale) Tuple[float, float]

Note

available in Python bindings as markerOffset2

markerOffsetWithWidthAndHeight(self, context: QgsSymbolRenderContext, width: float, height: float) Tuple[float, float]

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context – symbol render context

  • width – marker width

  • height – marker height

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

Note

available in Python as markerOffsetWithWidthAndHeight

outputUnit(self) Qgis.RenderUnit
Return type:

Qgis.RenderUnit

parameters(self) Dict[str, QgsProperty]

Returns the dynamic SVG parameters

New in version 3.18.

Return type:

Dict[str, QgsProperty]

path(self) str

Returns the marker SVG path.

See also

setPath()

Return type:

str

prepareExpressions(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

preservedAspectRatio(self) bool

Returns the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0.

Return type:

bool

properties(self) Dict[str, Any]
Return type:

Dict[str, Any]

removeMasks(self, context: QgsRenderContext, recursive: bool)

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

See also

prepareMasks()

See also

installMasks()

New in version 3.30.

renderPoint(self, point: QPointF | QPoint, context: QgsSymbolRenderContext)
Parameters:
resolvePaths(properties: Dict[str, Any], pathResolver: QgsPathResolver, saving: bool)

Turns relative paths in properties map to absolute when reading and vice versa when writing. Used internally when reading/writing symbols.

Parameters:
  • properties (Dict[str) –

  • pathResolver (QgsPathResolver) –

  • saving (bool) –

restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])

Restores older data defined properties from string map.

setFillColor(self, color: QColor | Qt.GlobalColor)
Parameters:

color (Union[QColor) –

setFixedAspectRatio(self, ratio: float)

Set the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering

Parameters:

ratio (float) – Fixed Aspect Ratio

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters:

scale (QgsMapUnitScale) –

setOutputUnit(self, unit: Qgis.RenderUnit)
Parameters:

unit (Qgis.RenderUnit) –

setParameters(self, parameters: Dict[str, QgsProperty])

Sets the dynamic SVG parameters

New in version 3.18.

Parameters:

parameters (Dict[str) –

setPath(self, path: str)

Set the marker SVG path.

Parameters:

path (str) – SVG path

See also

path()

setPreservedAspectRatio(self, par: bool) bool

Set preserved the marker aspect ratio between width and height.

Parameters:

par (bool) – Preserved Aspect Ratio

Return type:

bool

Returns:

the preserved aspect ratio value, True if fixed aspect ratio has been lower or equal to 0

setStrokeColor(self, c: QColor | Qt.GlobalColor)
Parameters:

c (Union[QColor) –

setStrokeWidth(self, w: float)
Parameters:

w (float) –

setStrokeWidthMapUnitScale(self, scale: QgsMapUnitScale)
Parameters:

scale (QgsMapUnitScale) –

setStrokeWidthUnit(self, unit: Qgis.RenderUnit)

Sets the units for the stroke width.

Parameters:

unit (Qgis.RenderUnit) – width units

shouldRenderUsingSelectionColor(self, context: QgsSymbolRenderContext) bool

Returns True if the symbol layer should be rendered using the selection color from the render context.

New in version 3.34.

startRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

stopRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

strokeColor(self) QColor
Return type:

QColor

strokeWidth(self) float
Return type:

float

strokeWidthMapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

strokeWidthUnit(self) Qgis.RenderUnit

Returns the units for the stroke width.

Return type:

Qgis.RenderUnit

updateDefaultAspectRatio(self) float

Calculates the default marker aspect ratio between width and height.

Return type:

float

Returns:

the default aspect ratio value

usedAttributes(self, context: QgsRenderContext) Set[str]
Parameters:

context (QgsRenderContext) –

Return type:

Set[str]

usesMapUnits(self) bool
Return type:

bool

writeDxf(self, e: QgsDxfExport, mmMapUnitScaleFactor: float, layerName: str, context: QgsSymbolRenderContext, shift: QPointF | QPoint = QPointF(0, 0)) bool
Parameters:
Return type:

bool

writeSldMarker(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])
Parameters:
  • doc (QDomDocument) –

  • element (QDomElement) –

  • props (Dict[str) –