Class: QgsLayoutAtlas

class qgis.core.QgsLayoutAtlas(layout: QgsLayout)

Bases: PyQt5.QtCore.QObject, QgsAbstractLayoutIterator, QgsLayoutSerializableObject

Constructor for new QgsLayoutAtlas.

Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector layer.

QgsLayoutAtlas implement the QgsAbstractLayoutIterator interface, allowing them to be used directly with QgsLayoutExporter to automatically output all pages from the atlas.

For QgsPrintLayout layouts, it is not necessary to manually construct a QgsLayoutAtlas object. Instead, the atlas attached to the print layout should be used. This can be retrieved by calling QgsPrintLayout.atlas()

New in version 3.0.

Parameters

layout

beginRender(self) → bool
Return type

bool

changed

Emitted when one of the atlas parameters changes. [signal]

childEvent()
connectNotify()
count(self) → int
Return type

int

coverageLayer(self) → QgsVectorLayer

Returns the coverage layer used for the atlas features.

Return type

QgsVectorLayer

coverageLayerChanged

Emitted when the coverage layer for the atlas changes. [signal]

currentFeatureNumber(self) → int

Returns the current feature number, where a value of 0 corresponds to the first feature.

Return type

int

currentFilename(self) → str

Returns the current feature filename.

Return type

str

customEvent()
disconnectNotify()
enabled(self) → bool

Returns whether the atlas generation is enabled

See also

setEnabled()

Return type

bool

endRender(self) → bool
Return type

bool

featureChanged

Is emitted when the current atlas feature changes. [signal]

filePath(self, baseFilePath: str, extension: str) → str
Parameters
  • baseFilePath (str) –

  • extension (str) –

Return type

str

filenameExpression(self) → str

Returns the filename expression used for generating output filenames for each atlas page.

Return type

str

filterExpression(self) → str

Returns the expression used for filtering features in the coverage layer.

This property has no effect is filterFeatures() is false.

See also

filterFeatures()

Return type

str

filterFeatures(self) → bool

Returns true if features should be filtered in the coverage layer.

Return type

bool

first(self) → bool

Seeks to the first feature, returning false if no feature was found.

See also

next()

See also

previous()

See also

last()

See also

seekTo()

Return type

bool

hideCoverage(self) → bool

Returns true if the atlas is set to hide the coverage layer.

Return type

bool

isSignalConnected()
last(self) → bool

Seeks to the last feature, returning false if no feature was found.

See also

next()

See also

previous()

See also

first()

See also

seekTo()

Return type

bool

layout(self) → QgsLayout
Return type

QgsLayout

messagePushed

Is emitted when the atlas has an updated status bar message. [signal]

nameForPage(self, page: int) → str

Returns the calculated name for a specified atlas page number. Page numbers start at 0.

Parameters

page (int) –

Return type

str

next(self) → bool
Return type

bool

numberFeaturesChanged

Emitted when the number of features for the atlas changes. [signal]

pageNameExpression(self) → str

Returns the expression (or field name) used for calculating the page name.

See also

nameForPage()

Return type

str

previous(self) → bool

Iterates to the previous feature, returning false if no previous feature exists.

See also

next()

See also

last()

See also

first()

See also

seekTo()

Return type

bool

readXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
Parameters
Return type

bool

receivers()
refreshCurrentFeature(self)

Refreshes the current atlas feature, by refetching its attributes from the vector layer provider

renderBegun

Emitted when atlas rendering has begun. [signal]

renderEnded

Emitted when atlas rendering has ended. [signal]

seekTo(self, feature: int) → bool

Seeks to the specified feature number.

See also

first()

See also

previous()

See also

next()

See also

last()

seekTo(self, feature: QgsFeature) -> bool Seeks to the specified feature.

See also

first()

See also

previous()

See also

next()

See also

last()

Parameters

feature (int) –

Return type

bool

sender()
senderSignalIndex()
setCoverageLayer(self, layer: QgsVectorLayer)

Sets the coverage layer to use for the atlas features.

See also

coverageLayer()

Parameters

layer (QgsVectorLayer) –

setEnabled(self, enabled: bool)

Sets whether the atlas is enabled.

See also

enabled()

Parameters

enabled (bool) –

setFilenameExpression(self, expression: str) → Tuple[bool, str]

Sets the filename expression used for generating output filenames for each atlas page. If an invalid expression is passed, false will be returned and errorString will be set to the expression error.

Parameters

expression (str) –

Return type

Tuple[bool, str]

setFilterExpression(self, expression: str) → Tuple[bool, str]

Sets the expression used for filtering features in the coverage layer.

This property has no effect is filterFeatures() is false.

If an invalid expression is passed, false will be returned and errorString will be set to the expression error.

Parameters

expression (str) –

Return type

Tuple[bool, str]

setFilterFeatures(self, filtered: bool)

Sets whether features should be filtered in the coverage layer.

See also

filterFeatures()

Parameters

filtered (bool) –

setHideCoverage(self, hide: bool)

Sets whether the coverage layer should be hidden in map items in the layouts.

See also

hideCoverage()

Parameters

hide (bool) –

setPageNameExpression(self, expression: str)

Sets the expression (or field name) used for calculating the page name.

Parameters

expression (str) –

setSortAscending(self, ascending: bool)

Sets whether features should be sorted in an ascending order.

This property has no effect is sortFeatures() is false.

See also

sortAscending()

Parameters

ascending (bool) –

setSortExpression(self, expression: str)

Sets the expression (or field name) to use for sorting features.

This property has no effect is sortFeatures() is false.

See also

sortExpression()

Parameters

expression (str) –

setSortFeatures(self, enabled: bool)

Sets whether features should be sorted in the atlas.

See also

sortFeatures()

Parameters

enabled (bool) –

sortAscending(self) → bool

Returns true if features should be sorted in an ascending order.

This property has no effect is sortFeatures() is false.

See also

sortFeatures()

See also

sortExpression()

Return type

bool

sortExpression(self) → str

Returns the expression (or field name) to use for sorting features.

This property has no effect is sortFeatures() is false.

See also

sortFeatures()

See also

sortAscending()

Return type

str

sortFeatures(self) → bool

Returns true if features should be sorted in the atlas.

See also

sortAscending()

See also

sortExpression()

Return type

bool

stringType(self) → str
Return type

str

timerEvent()
toggled

Emitted when atlas is enabled or disabled. [signal]

updateFeatures(self) → int

Requeries the current atlas coverage layer and applies filtering and sorting. Returns number of matching features.

Return type

int

writeXml(self, parentElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
Parameters
  • parentElement (QDomElement) –

  • document (QDomDocument) –

  • context (QgsReadWriteContext) –

Return type

bool