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.
2 Answers
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.
-
I'm searching for a shell command line (like ogr2ogr, grass...). I'v try most of them I didn't find one witch satisfy my needs :( . I want to merge tow vector files (polygons) with keeping the attribute table of the fist one and later dissolve the polygons witch overly Nov 25, 2016 at 10:31
-
Here you find how to merge 2 Shapefiles with OGR. However, The PyQGIS command I put in my answer can also run in the OS console, as a standalone script, without opening QGIS GUI. Would be that OK for your use case? Nov 25, 2016 at 12:39
-
The purpose is to dissolve polygons from layer1 witch overlap with polygons of layer2 keeping attributes table of layer1 and using a shell command line. can you please help me to do that ? Nov 28, 2016 at 14:13
-
@Mounirsky - I would suggest asking a new question and expand on the details which you mentioned in your last comment. You should also accept an answer provided to you by clicking the green-faded tick on the left-hand side of the answer you feel solved your initial problem :)– JosephNov 29, 2016 at 12:15
You can find all algorithms by typing processing.alglist()
.
You want to search for merging layers so type processing.alglist("merge")
.
Then choose one you need, e. g. processing.alghelp("qgis:mergevectorlayers")
for more information.
-
The purpose is to dissolve polygons from layer1 witch overlap with polygons of layer2 keeping attributes table of layer1 and using a shell command line. can you please help me to do that ? Nov 28, 2016 at 14:13