I need to create a stand-alone script for opening a QGIS template project, modify a layer data source, export the Composition and finally save the modified .qgs project into a new file. So far I have only found some examples for QGIS plugins, but of course they don't work for the stand-alone uses. Can anybody give me some helpful hints? Thanks!
- you can use PyQGIS from outside QGIS (search in gis.stackexchange)
- otherwise, a QGIS project file ( .qgs) is a simple XML file and there are many Python modules to process XML files:
part of a .qgs/XML file:
from xml.etree import ElementTree as ET with open('test.qgs', 'r') as f: tree = ET.parse(f) for elem in tree.findall('.//mapcanvas'): print("units: "), elem.find('units').text units : meters .....