Some notes on reading individual layers out of a Qgis Project file. This should end up in a 'import layers from a project file' plugin.
1. get the xml into some text:
xml = file("project.qgs").read()
2. make a blank QDomDocument and set the content:
d = PyQt4.QtXml.QDomDocument()
d.setContent(xml)
3. Now find the maplayers:
maps = d.elementsByTagName("maplayer")
4. How many?
maps.length()
5. Now read the fourth layer (0-index) into running Qgis:
QgsProject.instance().read(maps.item(3))
Wrap this in a nice gui that tells the user what the map layers are, lets them check boxes, import the layers, marks the current project as dirty. Jobzagoodun.
No comments:
Post a Comment