Wednesday, 12 December 2018

pyqgis - How to get the command line of QGIS algorithm "Merge vector layers"?


To insert this function to my program I want to know what is command line executed by the algorithm "Merge vector layers" using QGIS GUI.



Answer



After you run an algorithm from the Processing Toolbox, you can go to Processing -> History... -> ALGORITHM and you'll find the Python command to call the algorithm with the parameters you specified via GUI. For instance:


processing.runalg("qgis:mergevectorlayers",

"/docs/geodata/AMAZONAS.shp;/docs/geodata/PUTUMAYO.shp",
"/docs/merged.shp")

You would need to import the processing module before running the algorithm from the QGIS Python Console:


import processing
processing.runalg("qgis:mergevectorlayers",
"/docs/geodata/AMAZONAS.shp;/docs/geodata/PUTUMAYO.shp",
"/docs/merged.shp")

It's very helpful to understand the parameters of the algoritm, which you can achieve by following @DIVAD's recommendation.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...