Compare commits

..

3 Commits

Author SHA1 Message Date
bd86431755 Define input outputs 2024-04-14 16:23:04 -04:00
e393641c42 Use print object to show data count 2024-04-14 16:21:45 -04:00
308c0fb1d2 Add area 2024-04-14 16:07:36 -04:00
2 changed files with 54 additions and 72 deletions

View File

@ -1,42 +1,4 @@
from scrub_layer_class import * from input_paths_and_layers 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': ''
}
# Making folders for the output data layers # Making folders for the output data layers
create_output_folders(output_paths, output_paths_dir) create_output_folders(output_paths, output_paths_dir)
@ -60,13 +22,12 @@ nrcan.fix_geometries(output_paths['Fixed NRCan'])
nrcan_fixed = \ nrcan_fixed = \
ScrubLayer(qgis_path, output_paths['Fixed NRCan'], 'Fixed NRCan') ScrubLayer(qgis_path, output_paths['Fixed NRCan'], 'Fixed NRCan')
nrcan_fixed.create_spatial_index() nrcan_fixed.create_spatial_index()
print(f'Data Count of the NRCan layer after fixing geometries ' print(nrcan_fixed)
f'({nrcan_fixed.layer_name}): {nrcan_fixed.data_count}')
# Processing the GeoIndex layer includes fixing its geometries and # Processing the GeoIndex layer includes fixing its geometries and
# clipping it based on the Montreal boundary data layer # clipping it based on the Montreal boundary data layer
print('Processing the GeoIndex 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.create_spatial_index()
geo_index.fix_geometries(output_paths['Fixed GeoIndex']) 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'], geo_index_fixed = ScrubLayer(qgis_path, output_paths['Fixed GeoIndex'],
'Fixed GeoIndex') 'Fixed GeoIndex')
geo_index_fixed.create_spatial_index() geo_index_fixed.create_spatial_index()
print(f'Data Count of the GeoIndex layer after fixing geometries ' print(geo_index_fixed)
f'({geo_index_fixed.layer_name}): {geo_index_fixed.data_count}')
geo_index_fixed.clip_layer(montreal_boundary.layer_path, geo_index_fixed.clip_layer(montreal_boundary.layer_path,
output_paths['Clipped Fixed GeoIndex']) output_paths['Clipped Fixed GeoIndex'])
geo_index_clipped = \ geo_index_clipped = \
ScrubLayer(qgis_path, ScrubLayer(qgis_path,
output_paths['Clipped Fixed GeoIndex'], 'Clipped Fixed GeoIndex') output_paths['Clipped Fixed GeoIndex'], 'Clipped Fixed GeoIndex')
geo_index_clipped.create_spatial_index() geo_index_clipped.create_spatial_index()
print(f'Data Count of the {geo_index_fixed.layer_name} ' print(geo_index_clipped)
f' after clipping it '
f'based on the Montreal Boundary layer ({geo_index_clipped.layer_name}): '
f'{geo_index_clipped.layer.featureCount()}')
# Processing the Property Assessment layer includes a pairwise clip, and # Processing the Property Assessment layer includes a pairwise clip, and
# two spatial join with NRCan and GeoIndex layers, respectively # two spatial join with NRCan and GeoIndex layers, respectively
print(f'Data Count of the Property Assessment layer:' print(property_assessment)
f' {property_assessment.data_count}')
property_assessment.create_spatial_index() property_assessment.create_spatial_index()
# For the pairwise clip, number of overlaying layers can be chosen # 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'], output_paths['Pairwise Clipped Merged Property Assessment'],
'Clipped Property Assessment') 'Clipped Property Assessment')
print(f'Data Count of the Property Assessment layer ' print(clipped_property_assessment)
f'after the pairwise clipped with NRCan layer '
f'({clipped_property_assessment.layer_name}):'
f' {clipped_property_assessment.data_count}')
clipped_property_assessment.create_spatial_index() clipped_property_assessment.create_spatial_index()
clipped_property_assessment.spatial_join( clipped_property_assessment.spatial_join(
@ -136,10 +89,7 @@ property_assessment_nrcan = ScrubLayer(
output_paths['Property Assessment and NRCan'], output_paths['Property Assessment and NRCan'],
'Property Assessment and NRCan') 'Property Assessment and NRCan')
print(f'Data Count of the Property Assessment layer ' print(property_assessment_nrcan)
f'after its spatial join with NRCan layer '
f'({property_assessment_nrcan.layer_name}):'
f' {property_assessment_nrcan.data_count}')
property_assessment_nrcan.create_spatial_index() property_assessment_nrcan.create_spatial_index()
property_assessment_nrcan.spatial_join( property_assessment_nrcan.spatial_join(
@ -151,11 +101,7 @@ property_assessment_nrcan_geo = ScrubLayer(
output_paths['Property Assessment and NRCan and GeoIndex'], output_paths['Property Assessment and NRCan and GeoIndex'],
'Property Assessment and NRCan and GeoIndex') 'Property Assessment and NRCan and GeoIndex')
print(f'Data Count of the Property Assessment-NRCan layer ' print(property_assessment_nrcan_geo)
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}')
property_assessment_nrcan_geo.create_spatial_index() property_assessment_nrcan_geo.create_spatial_index()
property_assessment_nrcan_geo.delete_duplicates( property_assessment_nrcan_geo.delete_duplicates(
@ -166,10 +112,7 @@ deleted_dups_layer = ScrubLayer(
output_paths['Deleted Duplicates Layer'], output_paths['Deleted Duplicates Layer'],
'Deleted Duplicates Layer') 'Deleted Duplicates Layer')
print(f'Data Count of the Property Assessment-NRCan-GeoIndex layer ' print(deleted_dups_layer)
f'after deleting duplicates: {deleted_dups_layer.data_count}\n'
f'Name of the new layer: '
f'{deleted_dups_layer.layer_name}')
property_assessment_nrcan_geo.create_spatial_index() property_assessment_nrcan_geo.create_spatial_index()
property_assessment_nrcan_geo.multipart_to_singleparts( property_assessment_nrcan_geo.multipart_to_singleparts(
@ -180,13 +123,14 @@ single_parts_layer = ScrubLayer(
output_paths['Single Parts Layer'], output_paths['Single Parts Layer'],
'Single Parts Layer') 'Single Parts Layer')
print(f'Data Count of the Deleted Duplicates layer ' print(single_parts_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}')
single_parts_layer.create_spatial_index() single_parts_layer.create_spatial_index()
# The process of instantiating a new layer # The process of instantiating a new layer
# (including print and create part) can be a method # (including print and create part) can be a method
# Also experiment importing input_paths_and_layers # Also experiment importing input_paths_and_layers
# Add an area field
single_parts_layer.add_field('Area')
single_parts_layer.assign_area('Area')

View File

@ -0,0 +1,38 @@
from scrub_layer_class 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'
# 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': '',
'Single Parts Layer': ''
}