diff --git a/varennes_single_processes/remove_nrcan_duplicates.py b/varennes_single_processes/remove_nrcan_duplicates.py index abe6632..19bea38 100644 --- a/varennes_single_processes/remove_nrcan_duplicates.py +++ b/varennes_single_processes/remove_nrcan_duplicates.py @@ -19,6 +19,24 @@ duplcated = 'C:/Users/a_adli/PycharmProjects/varennes_gis_oo/' \ # First, the layer will be duplicated as some records are going to be removed -nrcan_varennes = ScrubLayer(qgis_path, nrcan_varennes, 'NRCan Varennes') -nrcan_varennes_duplicate = nrcan_varennes.duplicate_layer( +varennes_nrcan = ScrubLayer(qgis_path, nrcan_varennes, 'NRCan Varennes') +varennes_nrcan_duplicate = varennes_nrcan.duplicate_layer( duplcated, 'NRCan duplicated') + +tolerance = 5 +varennes_nrcan_features = varennes_nrcan.layer.getFeatures() +varennes_nrcan_duplicate_features = \ + varennes_nrcan_duplicate.layer.getFeatures() + +for feature in varennes_nrcan_features: + for next_feature in varennes_nrcan_duplicate_features: + if feature['feature_id'] == next_feature['feature_id']: + continue + if abs(feature['centroid_x'] - next_feature['centroid_x']) < tolerance\ + or \ + abs( + feature['centroid_y'] - next_feature['centroid_y'] + ) < tolerance: + record_id = next_feature.id() + varennes_nrcan_duplicate.delete_record_by_index(record_id) +