Add merge_layers

This commit is contained in:
Alireza Adli 2024-02-26 12:06:18 -05:00
parent d713c1b250
commit 7289f82d1a

View File

@ -0,0 +1,26 @@
from qgis.core import QgsApplication, QgsVectorLayer, QgsProcessingFeedback
from qgis.analysis import QgsNativeAlgorithms
import processing
from services_scripts.basic_functions import find_shp_files
root_folder = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/aEndeavor/clip_all'
layers_path = find_shp_files(root_folder)
# Set the path to QGIS installation
QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.34.1/apps/qgis", True)
# Initialize QGIS application
qgs = QgsApplication([], False)
qgs.initQgis()
# Add native algorithms provider
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
merged_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/aEndeavor/merged_all/merge_divisions.shp'
params = {'LAYERS': layers_path,
'CRS': None,
'OUTPUT': merged_layer}
processing.run("native:mergevectorlayers", params)