I'm building a plugin to perform Multi Criteria Analysis (yes another one...). As part of my workflow intersecting vectorlayers is needed. I use QgsOverlayAnalyzer.intersection (a pity union is not yet supported as far as I know).
Because intersection is limited to 2 layers a number of inbetween results is generated. Until now I create these inbetween results as shapefiles, add them to the TOC, use them in another intersection step and eventually remove them later.
Sample code (path, intersectionlayer1 and 2 are defined)
productname= "intersection_output1" # first inbetween result
product = QFileDialog.getSaveFileName(self.pluginGui,"Save inbetween result as", path, "shapefiles (*.shp)")
QgsOverlayAnalyzer().intersection(intersectionlayer1, intersectionlayer2, product, 0)
self.iface.addVectorLayer(product, productname, 'ogr')
Not very elegant and therefore I have a few questions:
- how to bypass adding the inbetween results to the TOC (QgsMapLayerRegistry requires them isn't it) ? Just using disk as storage is an improvement.
- how to store these inbetween results in memory (Plugin) layers ? This would improve processing speed and removal of inbetween results is easy.
No comments:
Post a Comment