Add find lass file
This commit is contained in:
parent
f2ac95a514
commit
632e853722
|
@ -1,6 +1,16 @@
|
||||||
|
"""
|
||||||
|
basic_functions module
|
||||||
|
A number of functionalities that help the project
|
||||||
|
but cannot be a part of the PyQGIS tool.
|
||||||
|
Project Developer: Alireza Adli alireza.adli@concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import time
|
import processing
|
||||||
|
|
||||||
|
from qgis.core import QgsApplication
|
||||||
|
from qgis.analysis import QgsNativeAlgorithms
|
||||||
|
|
||||||
|
|
||||||
def find_shp_files(root_folder):
|
def find_shp_files(root_folder):
|
||||||
|
@ -13,6 +23,16 @@ def find_shp_files(root_folder):
|
||||||
return shp_files
|
return shp_files
|
||||||
|
|
||||||
|
|
||||||
|
def find_las_files(root_folder):
|
||||||
|
las_files = []
|
||||||
|
# Sort folders alphabetically
|
||||||
|
for foldername, _, _ in sorted(os.walk(root_folder)):
|
||||||
|
for filename in sorted(glob.glob(os.path.join(foldername, '*.las'))):
|
||||||
|
new_file_name = filename.replace('\\', r'/')
|
||||||
|
las_files.append(new_file_name)
|
||||||
|
return las_files
|
||||||
|
|
||||||
|
|
||||||
def create_folders(directory, num_folders):
|
def create_folders(directory, num_folders):
|
||||||
"""
|
"""
|
||||||
Create a specified number of folders in the given directory.
|
Create a specified number of folders in the given directory.
|
||||||
|
@ -41,4 +61,15 @@ def create_output_folders(paths_dict, output_dir):
|
||||||
if path[-1] != 's':
|
if path[-1] != 's':
|
||||||
paths_dict[path] = output_path + f'/{new_folder}.shp'
|
paths_dict[path] = output_path + f'/{new_folder}.shp'
|
||||||
else:
|
else:
|
||||||
paths_dict[path] = output_path
|
paths_dict[path] = output_path
|
||||||
|
|
||||||
|
|
||||||
|
def merge_las_layers(layers_path, mergeded_layer_path):
|
||||||
|
merging_layers = find_las_files(layers_path)
|
||||||
|
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||||
|
|
||||||
|
params = {'LAYERS': merging_layers,
|
||||||
|
'CRS': None,
|
||||||
|
'OUTPUT': mergeded_layer_path}
|
||||||
|
|
||||||
|
processing.run("native:mergevectorlayers", params)
|
Loading…
Reference in New Issue
Block a user