Add intersection and spatial join (pairwise clip is done)
This commit is contained in:
parent
cca682871c
commit
76abe74837
@ -101,4 +101,42 @@ params_create_index_property_assessment = {'INPUT': property_assessment_layer, '
|
||||
processing.run("native:createspatialindex", params_create_index_property_assessment)
|
||||
print(f'Creating spatial index for {property_assessment_layer_name} is completed.')
|
||||
|
||||
intersection_nrcan_property_layer = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/tests/intersection_nrcan_property/intersection_nrcan_property.shp'
|
||||
|
||||
# A. Intersection by inputting NRCan and assigning property assessment as the overlay
|
||||
# (Three steps replace the pairwise clip where input is the property assessment and the overlay is the clipped nrcan)
|
||||
# We call these three steps A, B and C respectively
|
||||
params_intersection_nrcan_property_assessment = \
|
||||
{'INPUT': clipped_nrcan,
|
||||
'INPUT_FIELDS': [], 'OVERLAY_FIELDS': [], 'OVERLAY_FIELDS_PREFIX': '',
|
||||
'OUTPUT': intersection_nrcan_property_layer, 'GRID_SIZE': None}
|
||||
processing.run("native:intersection", params)
|
||||
|
||||
intersection_nrcan_property_read, intersection_nrcan_property_layer_name = load_layer(property_assessment_layer, 'Property Assesment')
|
||||
print(f'{intersection_nrcan_property_layer_name} data count: {intersection_nrcan_property_read.featureCount()}')
|
||||
|
||||
# Creating spatial index fo the result of the previous intersection
|
||||
params_create_index_intersection_nrcan = {'INPUT': intersection_nrcan_property_layer, 'OUTPUT': 'Output'}
|
||||
processing.run("native:createspatialindex", params_create_index_intersection_nrcan)
|
||||
print(f'Creating spatial index for {intersection_nrcan_property_layer_name} is completed.')
|
||||
|
||||
# B. Spatial Join (in QGIS: join attributes by location), with the NRCan as input
|
||||
# and the result of previous intersection as overlay
|
||||
output_layer_path = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/data/tests/join_nrcan_intersected_nrcan/py_joined_12.shp'
|
||||
|
||||
params_spatial_join_nrcan_intersection = \
|
||||
{'INPUT': clipped_nrcan,
|
||||
'PREDICATE': [0],
|
||||
'JOIN': intersection_nrcan_property_layer,
|
||||
'JOIN_FIELDS': [],
|
||||
'METHOD': 0,
|
||||
'DISCARD_NONMATCHING': False,
|
||||
'PREFIX': '',
|
||||
'OUTPUT': output_layer_path}
|
||||
|
||||
feedback_spatial_join_nrcan_intersection = QgsProcessingFeedback()
|
||||
processing.run('native:joinattributesbylocation', params,
|
||||
feedback=feedback_spatial_join_nrcan_intersection)
|
||||
|
||||
|
||||
qgs.exitQgis()
|
Loading…
Reference in New Issue
Block a user