From 35d58c67f0da3f146e840a2da8febac1c954ecd4 Mon Sep 17 00:00:00 2001 From: Alireza Adli Date: Thu, 28 Mar 2024 19:27:28 -0400 Subject: [PATCH] Add clip with several overlays method --- scrub_mtl_class.py | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/scrub_mtl_class.py b/scrub_mtl_class.py index 5bf079f..4592f4e 100644 --- a/scrub_mtl_class.py +++ b/scrub_mtl_class.py @@ -79,9 +79,40 @@ class ScrubMTL: f'{geo_index_clipped.layer.featureCount()}') def process_property_assesment(self): - print(f'Data Count of the GeoIndex layer: {self.property_assessment.data_count}') + print(f'Data Count of the GeoIndex layer: ' + f'{self.property_assessment.data_count}') self.property_assessment.create_spatial_index() + def clip_with_several_overlays(self, input_layer_path, input_layer_name, + overlaying_layer_path, overlaying_layer_name, + number_of_overlays, splitted_layers_dir, + clipped_layers_dir): + """This method clips using desired number of overlay layers + by splitting a big overlaying layer. It uses the ScrubLayer class + clip_layer method.""" + overlaying_layer = \ + self.initialize_layer(overlaying_layer_path, overlaying_layer_name) + input_layer = \ + self.initialize_layer(input_layer_path, input_layer_name) + overlaying_layer.\ + split_layer(number_of_overlays, splitted_layers_dir, self.qgis_path) + create_folders(clipped_layers_dir, number_of_overlays) + for overlay_layer_num in range(number_of_overlays): + splitted_overlay_layer_path = \ + splitted_layers_dir + \ + f'/layer_{overlay_layer_num}/layer_{overlay_layer_num}.shp' + clipped_layer_partition_path = \ + clipped_layers_dir + \ + f'/layer_{overlay_layer_num}/layer_{overlay_layer_num}.shp' + input_layer.clip_layer(splitted_overlay_layer_path, + clipped_layer_partition_path) + clipped_layer = \ + self.initialize_layer(clipped_layer_partition_path, + f'clipped_layer_{overlay_layer_num}') + clipped_layer.create_spatial_index() + + print('Pairwise Clipping is completed.') + def refine_heights(self): pass