I am trying to change programmatically using python the grid on the map composer of QGIS.

Does anyone knows the syntax for this operation?

grid selection

1 Answer 1


The only solution I have found is to dynamically modify the xml of the composer using the following code.

from xml.etree.ElementTree import ElementTree
tree = ElementTree()
p = tree.parse("...\\print2.qpt")
for node in p.findall('Composition/ComposerMap/ComposerMapGrid'):
    if node.attrib['intervalX']:
    if node.attrib['intervalY']:
        node.set('intervalY', 'ValueOfY')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.