Important update is commenting two lines in the constructor to experiment
This commit is contained in:
parent
adee45be00
commit
edce488e2a
@ -14,9 +14,9 @@ class ScrubLayer:
|
||||
# Set the path to QGIS installation
|
||||
QgsApplication.setPrefixPath(self.qgis_path, True)
|
||||
|
||||
# Initialize QGIS application
|
||||
qgs = QgsApplication([], False)
|
||||
qgs.initQgis()
|
||||
# # Initialize QGIS application
|
||||
# qgs = QgsApplication([], False)
|
||||
# qgs.initQgis()
|
||||
|
||||
self.layer_path = layer_path
|
||||
self.layer_name = layer_name
|
||||
@ -77,10 +77,8 @@ class ScrubLayer:
|
||||
processing.run("native:clip", clip_layer_params)
|
||||
print(f'Clipping of {self.layer_name} is completed.')
|
||||
|
||||
def clip_by_multiple(self, number_of_partitions, overlay_layer_path, overlay_layers_dir, clipped_layers_dir):
|
||||
# overlay_layer = ScrubLayer(self.qgis_path, overlay_layer_path, 'Original Overlay Layer')
|
||||
# overlay_layer.split_layer(number_of_partitions, overlay_layers_dir)
|
||||
# create_folders(clipped_layers_dir, number_of_partitions)
|
||||
def clip_by_multiple(self, number_of_partitions, overlay_layers_dir, clipped_layers_dir):
|
||||
create_folders(clipped_layers_dir, number_of_partitions)
|
||||
for layer in range(number_of_partitions):
|
||||
overlay = overlay_layers_dir + f'/layer_{layer}/layer_{layer}.shp'
|
||||
clipped = clipped_layers_dir + f'/layer_{layer}/layer_{layer}.shp'
|
||||
@ -119,6 +117,17 @@ class ScrubLayer:
|
||||
new_layer = ScrubLayer(self.qgis_path, output_layer_path, 'Temp Layer')
|
||||
new_layer.create_spatial_index()
|
||||
|
||||
@staticmethod
|
||||
def merge_layers(layers_path, mergeded_layer_path):
|
||||
merging_layers = find_shp_files(layers_path)
|
||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||
|
||||
params = {'LAYERS': merging_layers,
|
||||
'CRS': None,
|
||||
'OUTPUT': mergeded_layer_path}
|
||||
|
||||
processing.run("native:mergevectorlayers", params)
|
||||
|
||||
def multipart_to_singleparts(self, singleparts_layer_path):
|
||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||
params = {'INPUT': self.layer,
|
||||
|
Loading…
Reference in New Issue
Block a user