From 42e23e12f4e36e5f59edc31dcb19c4008a022bcf Mon Sep 17 00:00:00 2001 From: Alireza Adli Date: Mon, 26 Feb 2024 12:24:58 -0500 Subject: [PATCH] Add delete duplicate in the services package --- services_scripts/delete_duplicates.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 services_scripts/delete_duplicates.py diff --git a/services_scripts/delete_duplicates.py b/services_scripts/delete_duplicates.py new file mode 100644 index 0000000..1ee4a27 --- /dev/null +++ b/services_scripts/delete_duplicates.py @@ -0,0 +1,21 @@ +from qgis.core import QgsApplication, QgsVectorLayer, QgsProcessingFeedback +from qgis.analysis import QgsNativeAlgorithms +import processing + +# In QGIS Delete Identical is named Delete Duplicates +# 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()) +layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/aEndeavor/merged_all_delete_columns/merge_divisions.shp' + +params = {'INPUT':'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/history/aEndeavor/qgis_spatial_pariwiseunitNrcan_geo|layername=spatial_with_geo', + 'OUTPUT':'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/history/aEndeavor/empty/delete_duplicates_02.shp'} +processing.run("native:deleteduplicategeometries", params) + +qgs.exitQgis() \ No newline at end of file