Skip to main content
edited wording
Source Link
Jochen Schwarze
  • 14.9k
  • 8
  • 54
  • 120

Since trying @Joseph'sabove answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console) for me

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.

Since trying @Joseph's answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console)

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.

Since trying above answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console) for me

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.

changed "above" into "@Joseph" as the answers change position depending on score
Source Link
gisnside
  • 7.9k
  • 2
  • 32
  • 74

Since trying the above@Joseph's answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console)

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.

Since trying the above answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console)

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.

Since trying @Joseph's answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console)

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.

Source Link
Jochen Schwarze
  • 14.9k
  • 8
  • 54
  • 120

Since trying the above answer causes an exception (l1 and l2 are both of type QgsVectorLayer, QGIS 2.18.17 Python console)

import processing
[...]
processing.runalg('qgis:mergevectorlayers', l1 + ";" + l2, None)
Traceback (most recent call last):
    File "<input>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'QgsVectorLayer' and 'str'

I've been trying

>>> merged = processing.runalg('qgis:mergevectorlayers', [l1, l2], None)
>>> merged['OUTPUT']
u'C:\\Users\\Jochen\\AppData\\Local\\Temp\\processing30eee19448ef42a497403dd3660cafcf\\82e112158f194f59a53e18d5020a9a9d\\OUTPUT.shp'

successfully.

So passing <ParameterMultipleInput> as a python list is a solution to this.