Class: QgsSvgMarkerSymbolLayer

class qgis.core.QgsSvgMarkerSymbolLayer(path: str, size: float = DEFAULT_SVGMARKER_SIZE, angle: float = DEFAULT_SVGMARKER_ANGLE, scaleMethod: QgsSymbol.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

param properties

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

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

QgsUnitTypes.RenderUnit

path

Returns the marker SVG path.

preservedAspectRatio

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

properties

rtype

Dict[str, str]

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

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.

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.

usesMapUnits

rtype

bool

writeDxf

param e

writeSldMarker

param doc

bounds(self, point: Union[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

New in version 2.9.

create(properties: Dict[str, str] = {})QgsSymbolLayer
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

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: QgsUnitTypes.RenderUnit, heightUnit: QgsUnitTypes.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)QgsUnitTypes.RenderUnit
Return type

QgsUnitTypes.RenderUnit

path(self)str

Returns the marker SVG path.

See also

setPath()

Return type

str

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, str]
Return type

Dict[str, str]

renderPoint(self, point: Union[QPointF, QPoint], context: QgsSymbolRenderContext)
Parameters
resolvePaths(properties: Dict[str, str], 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.

New in version 3.0.

Parameters
  • properties (Dict[str) –

  • pathResolver (QgsPathResolver) –

  • saving (bool) –

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

Restores older data defined properties from string map.

New in version 3.0.

setFillColor(self, color: Union[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: QgsUnitTypes.RenderUnit)
Parameters

unit (QgsUnitTypes.RenderUnit) –

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: Union[QColor, Qt.GlobalColor])
Parameters

c (Union[QColor) –

setStrokeWidth(self, w: float)
Parameters

w (float) –

setStrokeWidthMapUnitScale(self, scale: QgsMapUnitScale)
Parameters

scale (QgsMapUnitScale) –

setStrokeWidthUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the units for the stroke width.

Parameters

unit (QgsUnitTypes.RenderUnit) – width units

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)QgsUnitTypes.RenderUnit

Returns the units for the stroke width.

Return type

QgsUnitTypes.RenderUnit

updateDefaultAspectRatio(self)float

Calculates the default marker aspect ratio between width and height.

Return type

float

Returns

the default aspect ratio value

usesMapUnits(self)bool
Return type

bool

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

bool

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

  • element (QDomElement) –

  • props (Dict[str) –