0

I use QGIS 3.0.2, Windows 7, OSGeo4W64 to combine the shape files in the stand-alone code, but the output file is not created and the error message does not appear.

Calling help information about qgis: mergevectorlayers gives:

Algorithm "qgis: mergevectorlayers" not found.

qgis: union help info works in an stand-alone script.

qgis: mergevectorlayers help info works in the QGIS console:

enter image description here

I've read most of the repetitive topics of gis.stackexchange, but I can not find a solution to my problem.

What's wrong with my code?

Here is the code:

import sys
import qgis.core
qgis.core.QgsApplication.setPrefixPath(r'C:\OSGeo4W64\apps\qgis', True)
qgs = qgis.core.QgsApplication([], False)
qgs.initQgis()
sys.path.append(r'C:\OSGeo4W64\apps\qgis\python\plugins')
import processing
from processing.core.Processing import Processing
Processing.initialize()

# qgis:union is OK
print(processing.algorithmHelp("qgis:union"))

# can't find algorithms
print(processing.algorithmHelp("qgis:mergevectorlayers"))
print(processing.algorithmHelp("saga:mergevectorlayers"))
print(processing.algorithmHelp("native:mergevectorlayers"))

input_files_list = [r"W:\MODIS\shp_files\MOD03_2018-01-02.shp",
                    r"W:\MODIS\shp_files\MOD03_2018-01-01.shp",]
output_file_path = r"W:\MODIS\shp_files\Merged.shp"

print('saga:mergeshapeslayers')
processing.runalg('saga:mergeshapeslayers', input_files_list[0], input_files_list, output_file_path)
print('OK!')

print('qgis:mergeshapeslayers')
processing.runalg('qgis:mergeshapeslayers', input_files_list[0], input_files_list, output_file_path)
print('OK!')

qgs.exitQgis()

Output:

Union (qgis:union)

This algorithm creates a layer containing... [so on deleted]

Algorithm "qgis:mergevectorlayers" not found.
None
Algorithm "saga:mergevectorlayers" not found.
None
Algorithm "native:mergevectorlayers" not found.
None
saga:mergeshapeslayers

Process finished with exit code 1

marked as duplicate by Mr. Che, Community Jun 13 '18 at 6:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.