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

Parameters
  • path (str) –

  • size (float = DEFAULT_SVGMARKER_SIZE) –

  • angle (float = DEFAULT_SVGMARKER_ANGLE) –

  • scaleMethod

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()
copyPaintEffect()
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()
markerOffset2()
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()
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

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) –