From 117a474a1642ac01004c3bbb55aaf32394e6a0ba Mon Sep 17 00:00:00 2001 From: Alireza Adli Date: Wed, 28 Feb 2024 13:40:18 -0500 Subject: [PATCH] Add multipart to singleparts to the services --- services_scripts/adding_area_field.py | 0 services_scripts/multipart_to_singleparts.py | 23 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 services_scripts/adding_area_field.py create mode 100644 services_scripts/multipart_to_singleparts.py diff --git a/services_scripts/adding_area_field.py b/services_scripts/adding_area_field.py new file mode 100644 index 0000000..e69de29 diff --git a/services_scripts/multipart_to_singleparts.py b/services_scripts/multipart_to_singleparts.py new file mode 100644 index 0000000..4092cfb --- /dev/null +++ b/services_scripts/multipart_to_singleparts.py @@ -0,0 +1,23 @@ +from qgis.core import QgsApplication, QgsVectorLayer, QgsProcessingFeedback +from qgis.analysis import QgsNativeAlgorithms +import processing + +# 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()) + + +input_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/output_data/delete_dups_4_partitioned|layername=delete_dups__partitioned' +singled_parts_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/output_data/multi_to_single/multi_to_single2.shp' + +params = {'INPUT': input_layer, + 'OUTPUT': singled_parts_layer} +processing.run("native:multiparttosingleparts", params) + +qgs.exitQgis()