Add basic functions module & add merge layers to the workflow class (scrub_mtl_class)
This commit is contained in:
parent
bd6431c912
commit
ed5d972d60
14
basic_functions.py
Normal file
14
basic_functions.py
Normal file
@ -0,0 +1,14 @@
|
||||
import os
|
||||
import glob
|
||||
import time
|
||||
|
||||
|
||||
def find_shp_files(root_folder):
|
||||
shp_files = []
|
||||
# Sort folders alphabetically
|
||||
for foldername, _, _ in sorted(os.walk(root_folder)):
|
||||
for filename in sorted(glob.glob(os.path.join(foldername, '*.shp'))):
|
||||
new_file_name = filename.replace('\\', r'/')
|
||||
shp_files.append(new_file_name)
|
||||
return shp_files
|
||||
|
@ -3,6 +3,7 @@ from qgis.core import QgsApplication, QgsField, QgsProject, \
|
||||
QgsExpressionContext, QgsExpressionContextUtils, edit
|
||||
from qgis.PyQt.QtCore import QVariant
|
||||
from qgis.analysis import QgsNativeAlgorithms
|
||||
from basic_functions import *
|
||||
import processing
|
||||
|
||||
|
||||
@ -74,9 +75,6 @@ class ScrubLayer:
|
||||
processing.run("native:clip", clip_layer_params)
|
||||
print(f'Clipping of {self.layer_name} is completed.')
|
||||
|
||||
def merge_layers(self, layers_path, mered_layer_path):
|
||||
pass
|
||||
|
||||
def multipart_to_singleparts(self, singleparts_layer_path):
|
||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||
params = {'INPUT': self.layer,
|
||||
|
@ -1,4 +1,5 @@
|
||||
from scrub_layer_class import *
|
||||
from basic_functions import *
|
||||
|
||||
|
||||
class ScrubMTL:
|
||||
@ -9,6 +10,17 @@ class ScrubMTL:
|
||||
"""Can be a part of the constructor"""
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def merge_layers(layers_path, mered_layer_path):
|
||||
merging_layers = find_shp_files(layers_path)
|
||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||
|
||||
params = {'LAYERS': merging_layers,
|
||||
'CRS': None,
|
||||
'OUTPUT': mered_layer_path}
|
||||
|
||||
processing.run("native:mergevectorlayers", params)
|
||||
|
||||
def generate_output_paths(self):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user