2

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

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']:
        node.set('intervalX','ValueOfX)
    if node.attrib['intervalY']:
        node.set('intervalY', 'ValueOfY')
tree.write("..\print2.qpt")`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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