diff --git a/mtl_buildings_workflow.py b/mtl_buildings_workflow.py index ae58e38..451a783 100644 --- a/mtl_buildings_workflow.py +++ b/mtl_buildings_workflow.py @@ -4,7 +4,7 @@ from services_scripts.load_layer import load_layer import processing # Set the path to QGIS installation -QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.34.1/apps/qgis", True) +QgsApplication.setPrefixPath('C:/Program Files/QGIS 3.34.1/apps/qgis', True) # Initialize QGIS application qgs = QgsApplication([], False) @@ -25,15 +25,32 @@ print(f'Fixing {nrcan_name} geometries') fixed_nrcan = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/tests/python_fixed_04/py_fixes_04.shp' params_fixing_nrcan = {'INPUT': nrcan, 'METHOD': 0, 'OUTPUT': fixed_nrcan} -fixed_layer = processing.run("native:fixgeometries", params_fixing_nrcan)['OUTPUT'] +fixed_layer_nrcan = processing.run('native:fixgeometries', params_fixing_nrcan)['OUTPUT'] -fixed_nrcan, fixed_nrcan_name = load_layer(fixed_layer, 'Fixed NRCan') +fixed_nrcan, fixed_nrcan_name = load_layer(fixed_layer_nrcan, 'Fixed NRCan') print(f'{fixed_nrcan_name} data count: {fixed_nrcan.featureCount()}') -params_create_index_nrcan = {'INPUT': fixed_layer, 'OUTPUT': 'Output'} + +montreal_boundary_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/montreal_boundary|layername=Montreal_boundary' +clipped_nrcan_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/tests/clipped_nrcan/clipped_nrcan.shp' + +params_clipping_nrcan = {'INPUT': fixed_nrcan, 'OVERLAY': montreal_boundary_layer, 'FILTER_EXPRESSION': '', 'FILTER_EXTENT': None, 'OUTPUT': clipped_layer} +processing.run("native:clip", params_clipping_nrcan) + +print(f'Clipping of {fixed_nrcan_name} is completed.') + +clipped_nrcan, clipped_nrcan_name = load_layer(clipped_nrcan_layer, 'Clipped NRCan') +print(f'{clipped_nrcan_name} data count: {clipped_nrcan.featureCount()}') + + +params_create_index_nrcan = {'INPUT': clipped_nrcan, 'OUTPUT': 'Output'} indexed_layer = processing.run("native:createspatialindex", params_create_index_nrcan) +print(f'Creating spatial index for {clipped_nrcan_name} is completed.') -print("Creating spatial index is completed.") +geoindex_unclipped_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/Geoindex_81670/mamh_usage_predo_2022_s_poly.shp' +geoindex_unclipped, geoindex_unclipped_name = load_layer(geoindex_unclipped_layer, 'GeoIndex Unclipped') + +print(f'{geoindex_unclipped_name} data count: {geoindex_unclipped.featureCount()}') qgs.exitQgis() \ No newline at end of file