Class: QgsMapLayerFactory

class qgis.core.QgsMapLayerFactory

Bases: sip.wrapper

Contains utility functions for creating map layers.

New in version 3.18.1:

Methods

createLayer

Creates a map layer, given a uri, name, layer type and provider name.

typeFromString

Returns the map layer type corresponding a string value.

typeToString

Converts a map layer type to a string value.

class LayerOptions(transformContext: QgsCoordinateTransformContext)

Bases: sip.wrapper

Constructor for LayerOptions with transformContext.

QgsMapLayerFactory.LayerOptions(QgsMapLayerFactory.LayerOptions)

loadAllStoredStyles
loadDefaultStyle
transformContext
createLayer(uri: str, name: str, type: QgsMapLayerType, options: QgsMapLayerFactory.LayerOptions, provider: str = '') QgsMapLayer

Creates a map layer, given a uri, name, layer type and provider name.

Caller takes ownership of the returned layer.

New in version 3.22.

Parameters
Return type

QgsMapLayer

typeFromString(string: str) Tuple[QgsMapLayerType, bool]

Returns the map layer type corresponding a string value.

Parameters

string (str) – string to convert to map layer type

Return type

Tuple[QgsMapLayerType, bool]

Returns

  • converted map layer type

  • ok: will be set to True if string was successfully converted to a map layer type

See also

typeToString()

typeToString(type: QgsMapLayerType) str

Converts a map layer type to a string value.

See also

typeFromString()

Parameters

type (QgsMapLayerType) –

Return type

str