0

I need to use qgis:union in pyqgis algorithm and to merge 2 layers, layer1 and layer2 and "see" the output layer But i don´t understand how to work with the "output layer"

  1. this "output layer" have the layer1 and layer 2 features?
  2. how to save a "output layer"?

closed as off-topic by PolyGeo May 19 '18 at 6:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • It really depends on where it runnings (console, console from a script, standAlone application). The processing framework is very useful when you create workflow models but painful in a script. Also Which version of processing you are using ? (It maters for answer) – SIGIS Jun 23 '16 at 5:36
2

1) Yes and more see the doc


2) To retrieve output 2 possibilities :

  1. if you specify a path of the output it will set it as you mentiion it. ex :

    processing.runalg("qgis:union",layer1,layer2,"C:\path\to\your\shp")

  2. Second solution set the path None and it will write for you in the temp but you need to get it in a variable like so. The variable will be a dictionnary and to get it set the key of the dict.

    prOutput= processing.runalg("qgis:union",layer1,layer2,,None)
    prOutput= {'OUTPUT': u'C:\\Temp\\processingb88b658e8759402daa2ae3e0463e313c\\c92284916d824efcb2aab890c5fed045\\OUTPUT.shp'}  
    prOutput['OUTPUT'] = u'C:\\Temp\\processingb88b658e8759402daa2ae3e0463e313c\\c92284916d824efcb2aab890c5fed045\\OUTPUT.shp'
    

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