Class: QgsRasterFillSymbolLayer

class qgis.core.QgsRasterFillSymbolLayer

Bases: QgsImageFillSymbolLayer

A class for filling symbols with a repeated raster image.

QgsRasterFillSymbolLayer(imageFilePath: str = ‘’) Constructor for QgsRasterFillSymbolLayer, using a raster fill from the specified imageFilePath.

Enums

FillCoordinateMode

alias of SymbolCoordinateReference

Methods

applyBrushTransformFromContext

param context:

applyDataDefinedSettings

param context:

clone

rtype:

QgsRasterFillSymbolLayer

color

rtype:

QColor

coordinateMode

Coordinate mode for fill.

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 a new QgsRasterFillSymbolLayer from a properties map.

createFromSld

Creates a new QgsRasterFillSymbolLayer from a SLD element.

estimateMaxBleed

param context:

height

Returns the height used for scaling the image used in the fill.

imageFilePath

The path to the raster image used for the fill.

installMasks

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

layerType

rtype:

str

offset

Returns the offset for the fill.

offsetMapUnitScale

Returns the map unit scale for the fill's offset.

offsetUnit

Returns the units for the fill's offset.

opacity

Returns the opacity for the raster image used in the fill.

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

renderPolygon

param points:

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.

setCoordinateMode

Set the coordinate mode for fill.

setHeight

Sets the height for scaling the image.

setImageFilePath

Sets the path to the raster image used for the fill.

setOffset

Sets the offset for the fill.

setOffsetMapUnitScale

Sets the map unit scale for the fill's offset.

setOffsetUnit

Sets the units for the fill's offset.

setOpacity

Sets the opacity for the raster image used in the fill.

setOutputUnit

param unit:

setSizeMapUnitScale

Sets the map unit scale for the image's width and height.

setSizeUnit

Sets the unit for the image's width and height.

setSubSymbol

param symbol:

setWidth

Sets the width for scaling the image used in the fill.

setWidthMapUnitScale

Sets the map unit scale for the image's width.

setWidthUnit

Sets the unit for the image's width.

shouldRenderUsingSelectionColor

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

sizeMapUnitScale

Returns the map unit scale for the image's width and height.

sizeUnit

Returns the units for the image's width and height.

startRender

param context:

stopRender

param context:

subSymbol

rtype:

QgsSymbol

usesMapUnits

rtype:

bool

width

Returns the width used for scaling the image used in the fill.

widthMapUnitScale

Returns the map unit scale for the image's width.

widthUnit

Returns the units for the image's width.

FillCoordinateMode

alias of SymbolCoordinateReference

applyBrushTransformFromContext(self, context: QgsSymbolRenderContext = None) bool
Parameters:

context (QgsSymbolRenderContext = None) –

Return type:

bool

applyDataDefinedSettings(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

clone(self) QgsRasterFillSymbolLayer
Return type:

QgsRasterFillSymbolLayer

color(self) QColor
Return type:

QColor

coordinateMode(self) Qgis.SymbolCoordinateReference

Coordinate mode for fill. Controls how the top left corner of the image fill is positioned relative to the feature.

Return type:

Qgis.SymbolCoordinateReference

Returns:

coordinate mode

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 a new QgsRasterFillSymbolLayer from a properties map. The caller takes ownership of the returned object.

Parameters:

properties (Dict[str) –

Return type:

QgsSymbolLayer

createFromSld(element: QDomElement) QgsSymbolLayer

Creates a new QgsRasterFillSymbolLayer from a SLD element. The caller takes ownership of the returned object.

New in version 3.30.

Parameters:

element (QDomElement) –

Return type:

QgsSymbolLayer

estimateMaxBleed(self, context: QgsRenderContext) float
Parameters:

context (QgsRenderContext) –

Return type:

float

height(self) float

Returns the height used for scaling the image used in the fill.

If the height is 0 then the height will be calculated automatically based on the image’s width().

See also

width()

See also

setHeight()

New in version 3.36.

Return type:

float

imageFilePath(self) str

The path to the raster image used for the fill.

Return type:

str

Returns:

path to image file

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

offset(self) QPointF

Returns the offset for the fill.

Return type:

QPointF

Returns:

offset for fill

See also

setOffset()

See also

offsetUnit()

offsetMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the fill’s offset.

Return type:

QgsMapUnitScale

Returns:

map unit scale for offset

See also

offset()

See also

offsetUnit()

offsetUnit(self) Qgis.RenderUnit

Returns the units for the fill’s offset.

Return type:

Qgis.RenderUnit

Returns:

units for offset

See also

setOffsetUnit()

See also

offset()

opacity(self) float

Returns the opacity for the raster image used in the fill.

Return type:

float

Returns:

opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

setOpacity()

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.

renderPolygon(self, points: QPolygonF, rings: Iterable[QPolygonF], 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.

setCoordinateMode(self, mode: Qgis.SymbolCoordinateReference)

Set the coordinate mode for fill. Controls how the top left corner of the image fill is positioned relative to the feature.

Parameters:

mode (Qgis.SymbolCoordinateReference) – coordinate mode

See also

coordinateMode()

setHeight(self, height: float)

Sets the height for scaling the image.

If height is 0 then the height will be calculated automatically based on the image’s width().

See also

setWidth()

See also

height()

See also

width()

New in version 3.36.

Parameters:

height (float) –

setImageFilePath(self, imagePath: str)

Sets the path to the raster image used for the fill.

Parameters:

imagePath (str) – path to image file

See also

imageFilePath()

setOffset(self, offset: QPointF | QPoint | float)

Sets the offset for the fill.

Parameters:

offset (Union[QPointF) – offset for fill

See also

offset()

See also

setOffsetUnit()

setOffsetMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the fill’s offset.

Parameters:

scale (QgsMapUnitScale) – map unit scale for offset

See also

setOffset()

See also

setOffsetUnit()

setOffsetUnit(self, unit: Qgis.RenderUnit)

Sets the units for the fill’s offset.

Parameters:

unit (Qgis.RenderUnit) – units for offset

See also

offsetUnit()

See also

setOffset()

setOpacity(self, opacity: float)

Sets the opacity for the raster image used in the fill.

Parameters:

opacity (float) – opacity value between 0 (fully transparent) and 1 (fully opaque)

See also

opacity()

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

unit (Qgis.RenderUnit) –

setSizeMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the image’s width and height.

See also

setWidth()

See also

setHeight()

See also

setSizeUnit()

New in version 3.36.

Parameters:

scale (QgsMapUnitScale) –

setSizeUnit(self, unit: Qgis.RenderUnit)

Sets the unit for the image’s width and height.

See also

widthUnit()

See also

setWidth()

New in version 3.36.

Parameters:

unit (Qgis.RenderUnit) –

setSubSymbol(self, symbol: QgsSymbol) bool
Parameters:

symbol (QgsSymbol) –

Return type:

bool

setWidth(self, width: float)

Sets the width for scaling the image used in the fill.

If width is 0 then the width will be calculated automatically based on the image’s height().

See also

width()

See also

height()

See also

setHeight()

See also

setSizeUnit()

Parameters:

width (float) –

setWidthMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the image’s width.

See also

setWidth()

See also

setWidthUnit()

Deprecated since version use: setSizeMapUnitScale() instead.

Parameters:

scale (QgsMapUnitScale) –

setWidthUnit(self, unit: Qgis.RenderUnit)

Sets the unit for the image’s width.

See also

widthUnit()

See also

setWidth()

Deprecated since version use: setSizeUnit() instead.

Parameters:

unit (Qgis.RenderUnit) –

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.

sizeMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the image’s width and height.

See also

width()

See also

height()

See also

sizeUnit()

New in version 3.36.

Return type:

QgsMapUnitScale

sizeUnit(self) Qgis.RenderUnit

Returns the units for the image’s width and height.

See also

setSizeUnit()

See also

width()

See also

height()

New in version 3.36.

Return type:

Qgis.RenderUnit

startRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

stopRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext) –

subSymbol(self) QgsSymbol
Return type:

QgsSymbol

usesMapUnits(self) bool
Return type:

bool

width(self) float

Returns the width used for scaling the image used in the fill.

If the width is 0 then the width will be calculated automatically based on the image’s height().

See also

height()

See also

setWidth()

See also

sizeUnit()

Return type:

float

widthMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the image’s width.

See also

width()

See also

widthUnit()

Deprecated since version use: sizeMapUnitScale() instead.

Return type:

QgsMapUnitScale

widthUnit(self) Qgis.RenderUnit

Returns the units for the image’s width.

See also

setWidthUnit()

See also

width()

Deprecated since version use: sizeUnit() instead.

Return type:

Qgis.RenderUnit