diff --git a/scrub_layer_class.py b/scrub_layer_class.py index 832bf35..6521dc4 100644 --- a/scrub_layer_class.py +++ b/scrub_layer_class.py @@ -26,26 +26,40 @@ class ScrubLayer: QgsProject.instance().addMapLayer(the_layer) return the_layer + def fix_geometries(self, fixed_layer): + QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) + fix_geometries_params = { + 'INPUT': self.layer, + 'METHOD': 0, + 'OUTPUT': fixed_layer + } + processing.run("native:fixgeometries", fix_geometries_params) + def create_spatial_index(self): QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) create_spatial_index_params = { - 'INPUT': self.layer_path, + 'INPUT': self.layer, 'OUTPUT': 'Output' } processing.run("native:createspatialindex", create_spatial_index_params) + print(f'Creating spatial index for {self.layer_name} is completed.') + + def clip_layer(self, overlay_layer, clipped_layer): + QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms()) + clip_layer_params = { + 'INPUT': self.layer_path, + 'OVERLAY': overlay_layer, + 'FILTER_EXPRESSION': '', + 'FILTER_EXTENT': None, + 'OUTPUT': clipped_layer + } + processing.run("native:clip", clip_layer_params) + print(f'Clipping of {self.layer_name} is completed.') @staticmethod def cleanup(): QgsApplication.exitQgis() -if __name__ == '__main__': - app_path = 'C:/Program Files/QGIS 3.34.1/apps/qgis' - new_path = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' \ - 'data/test_data/test_input/nrcan_north/nrcan_north.shp' - data_layer_name = 'nrcan_north' - handle_layer = ScrubLayer(app_path, new_path, data_layer_name) - # print(handle_layer.layer.featureCount()) - handle_layer.create_spatial_index() diff --git a/scrub_mtl_class.py b/scrub_mtl_class.py new file mode 100644 index 0000000..9e0be9c --- /dev/null +++ b/scrub_mtl_class.py @@ -0,0 +1,32 @@ +from scrub_layer_class import * + + +class ScrubMTL: + def __init__(self): + pass + + def define_input_paths(self): + """Can be a part of the constructor""" + pass + + def generate_output_paths(self): + pass + + def initialize_layer(self): + pass + + def process_nrcan(self): + pass + + def process_geo_index(self): + pass + + def process_property_assesment(self): + pass + + def remove_redundant_fields(self): + pass + + def remove_records_by_area(self, area_limitation): + """Area limitation can be assigned in the constructor""" + pass