diff --git a/handle_mtl_ds_workflow.py b/handle_mtl_ds_workflow.py index ac7d32c..daf4fb2 100644 --- a/handle_mtl_ds_workflow.py +++ b/handle_mtl_ds_workflow.py @@ -1,42 +1,4 @@ -from scrub_layer_class import * -from basic_functions import * - -qgis_path = 'C:/Program Files/QGIS 3.34.1/apps/qgis' - -# Gathering input data layers paths -input_paths = { - 'NRCan': - 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' - 'data/input_data/nrcan/Autobuilding_QC_VILLE_MONTREAL.shp', - 'GeoIndex': - 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' - 'data/input_data/Geoindex_81670/mamh_usage_predo_2022_s_poly.shp', - 'Property Assessment': - 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' - 'data/input_data/property_assessment/uniteevaluationfonciere.shp', - 'Montreal Boundary': - 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' - 'data/input_data/montreal_boundary/Montreal_boundary.shp' -} - -# Defining a directory for all the output data layers -output_paths_dir = \ - 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' \ - 'data/gisoo_workflow_output_2' - -# Preparing a bedding for output data layers paths -output_paths = { - 'Fixed NRCan': '', - 'Fixed GeoIndex': '', - 'Clipped Fixed GeoIndex': '', - 'Splitted NRCans': '', - 'Pairwise Clipped Property Assessment Partitions': '', - 'Pairwise Clipped Merged Property Assessment': '', - 'Property Assessment and NRCan': '', - 'Property Assessment and NRCan and GeoIndex': '', - 'Deleted Duplicates Layer': '', - 'Singled Parts Layer': '' -} +from input_paths_and_layers import * # Making folders for the output data layers create_output_folders(output_paths, output_paths_dir) @@ -60,13 +22,12 @@ nrcan.fix_geometries(output_paths['Fixed NRCan']) nrcan_fixed = \ ScrubLayer(qgis_path, output_paths['Fixed NRCan'], 'Fixed NRCan') nrcan_fixed.create_spatial_index() -print(f'Data Count of the NRCan layer after fixing geometries ' - f'({nrcan_fixed.layer_name}): {nrcan_fixed.data_count}') +print(nrcan_fixed) # Processing the GeoIndex layer includes fixing its geometries and # clipping it based on the Montreal boundary data layer print('Processing the GeoIndex layer') -print(f'Data Count of the GeoIndex layer: {geo_index.data_count}') +print(geo_index) geo_index.create_spatial_index() geo_index.fix_geometries(output_paths['Fixed GeoIndex']) @@ -74,24 +35,19 @@ geo_index.fix_geometries(output_paths['Fixed GeoIndex']) geo_index_fixed = ScrubLayer(qgis_path, output_paths['Fixed GeoIndex'], 'Fixed GeoIndex') geo_index_fixed.create_spatial_index() -print(f'Data Count of the GeoIndex layer after fixing geometries ' - f'({geo_index_fixed.layer_name}): {geo_index_fixed.data_count}') +print(geo_index_fixed) geo_index_fixed.clip_layer(montreal_boundary.layer_path, output_paths['Clipped Fixed GeoIndex']) geo_index_clipped = \ ScrubLayer(qgis_path, output_paths['Clipped Fixed GeoIndex'], 'Clipped Fixed GeoIndex') geo_index_clipped.create_spatial_index() -print(f'Data Count of the {geo_index_fixed.layer_name} ' - f' after clipping it ' - f'based on the Montreal Boundary layer ({geo_index_clipped.layer_name}): ' - f'{geo_index_clipped.layer.featureCount()}') +print(geo_index_clipped) # Processing the Property Assessment layer includes a pairwise clip, and # two spatial join with NRCan and GeoIndex layers, respectively -print(f'Data Count of the Property Assessment layer:' - f' {property_assessment.data_count}') +print(property_assessment) property_assessment.create_spatial_index() # For the pairwise clip, number of overlaying layers can be chosen @@ -121,10 +77,7 @@ clipped_property_assessment = ScrubLayer( output_paths['Pairwise Clipped Merged Property Assessment'], 'Clipped Property Assessment') -print(f'Data Count of the Property Assessment layer ' - f'after the pairwise clipped with NRCan layer ' - f'({clipped_property_assessment.layer_name}):' - f' {clipped_property_assessment.data_count}') +print(clipped_property_assessment) clipped_property_assessment.create_spatial_index() clipped_property_assessment.spatial_join( @@ -136,10 +89,7 @@ property_assessment_nrcan = ScrubLayer( output_paths['Property Assessment and NRCan'], 'Property Assessment and NRCan') -print(f'Data Count of the Property Assessment layer ' - f'after its spatial join with NRCan layer ' - f'({property_assessment_nrcan.layer_name}):' - f' {property_assessment_nrcan.data_count}') +print(property_assessment_nrcan) property_assessment_nrcan.create_spatial_index() property_assessment_nrcan.spatial_join( @@ -151,11 +101,7 @@ property_assessment_nrcan_geo = ScrubLayer( output_paths['Property Assessment and NRCan and GeoIndex'], 'Property Assessment and NRCan and GeoIndex') -print(f'Data Count of the Property Assessment-NRCan layer ' - f'after its spatial join with GeoIndex layer:' - f' {property_assessment_nrcan_geo.data_count}\n' - f'Name of the new layer: ' - f'{property_assessment_nrcan_geo.layer_name}') +print(property_assessment_nrcan_geo) property_assessment_nrcan_geo.create_spatial_index() property_assessment_nrcan_geo.delete_duplicates( @@ -166,10 +112,7 @@ deleted_dups_layer = ScrubLayer( output_paths['Deleted Duplicates Layer'], 'Deleted Duplicates Layer') -print(f'Data Count of the Property Assessment-NRCan-GeoIndex layer ' - f'after deleting duplicates: {deleted_dups_layer.data_count}\n' - f'Name of the new layer: ' - f'{deleted_dups_layer.layer_name}') +print(deleted_dups_layer) property_assessment_nrcan_geo.create_spatial_index() property_assessment_nrcan_geo.multipart_to_singleparts( @@ -180,11 +123,7 @@ single_parts_layer = ScrubLayer( output_paths['Single Parts Layer'], 'Single Parts Layer') -print(f'Data Count of the Deleted Duplicates layer ' - f'after separating multiparts to clickable single parts: ' - f'{single_parts_layer.data_count}\n' - f'Name of the new layer: ' - f'{single_parts_layer.layer_name}') +print(single_parts_layer) single_parts_layer.create_spatial_index() # The process of instantiating a new layer