From c97ff67ca415d20215ac22e72f77013fe17b52e9 Mon Sep 17 00:00:00 2001 From: Alireza Adli Date: Sun, 19 May 2024 13:02:31 -0400 Subject: [PATCH] Add load_layer to the basic functions --- services_scripts/basic_functions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services_scripts/basic_functions.py b/services_scripts/basic_functions.py index 1b6c9bb..bf5914f 100644 --- a/services_scripts/basic_functions.py +++ b/services_scripts/basic_functions.py @@ -2,6 +2,16 @@ import os import glob import time +from qgis.core import QgsProject, QgsVectorLayer + + +def load_layer(path, layer_name): + the_layer = QgsVectorLayer(path, layer_name, 'ogr') + if not the_layer.isValid(): + print(f'{layer_name} failed to load!') + else: + QgsProject.instance().addMapLayer(the_layer) + return the_layer, layer_name def create_folders(directory, num_folders): """