Defining atlas feature margin using PyQGIS3

by Mar   Last Updated May 25, 2020 11:22 AM

I want to create a simple atlas composer map using PyQGIS3. My question is about atlas feature scale. I want to use this settings from image.

enter image description here

I know this select option but I don't know how to add some number percent for margin in first option ( layout.referenceMap().setAtlasScalingMode(QgsLayoutItemMap.Auto) )

layout.referenceMap().setAtlasScalingMode(QgsLayoutItemMap.Auto)
layout.referenceMap().setAtlasScalingMode(QgsLayoutItemMap.Predefined)
layout.referenceMap().setAtlasScalingMode(QgsLayoutItemMap.Fixed)

Any idea how to do this in PyQGIS3?



Answers 1


Look at

layout.referenceMap().atlasMargin(QgsLayoutObject.OriginalValue) # Get current value.
# You can replace above QgsLayoutObject.OriginalValue with QgsLayoutObject.EvaluatedValue
# if using an expression instead of a fixed value
layout.referenceMap().setAtlasMargin(yourvalue) # Set current value
ThomasG77
ThomasG77
May 25, 2020 10:48 AM

Related Questions


how to define correct atlas layers using PYQGIS?

Updated June 04, 2017 21:22 PM

PyQGIS composer add picture by layer path field

Updated May 23, 2020 01:22 AM

pyqgis3 atlas feature scale

Updated May 27, 2020 14:22 PM