Add processing NRCan and GeoIndex methods

This commit is contained in:
Alireza Adli 2024-03-28 18:09:03 -04:00
parent dac1dfb042
commit f91764184d

View File

@ -3,8 +3,9 @@ from basic_functions import *
class ScrubMTL: class ScrubMTL:
def __init__(self, nrcan, geoindex, property_assessment, def __init__(self, qgis_path, nrcan, geoindex, property_assessment,
montreal_boundary, output_paths_dir): montreal_boundary, output_paths_dir):
self.qgis_path = qgis_path
self.nrcan = nrcan self.nrcan = nrcan
self.geoindex = geoindex self.geoindex = geoindex
self.property_assessment = property_assessment self.property_assessment = property_assessment
@ -41,15 +42,43 @@ class ScrubMTL:
os.mkdir(output_path) os.mkdir(output_path)
self.output_paths[path] = output_path + f'/{new_folder}.shp' self.output_paths[path] = output_path + f'/{new_folder}.shp'
def initialize_layer(self): def initialize_layer(self, layer_path, layer_name):
pass return ScrubLayer(self.qgis_path, layer_path, layer_name)
def process_nrcan(self): def process_nrcan(self):
pass nrcan = self.initialize_layer(self.nrcan, 'NRCan')
print(f'Data Count of the NRCan layer: {nrcan.data_count}')
nrcan.create_spatial_index()
nrcan.fix_geometries(self.output_paths['Fixed NRCan'])
nrcan_fixed = \
self.initialize_layer(self.output_paths['Fixed NRCan'],
'Fixed NRCan')
nrcan_fixed.create_spatial_index()
print(f'Data Count of the NRCan layer ({nrcan_fixed.layer_name})'
f'after fixing geometries: {nrcan_fixed.layer.featureCount()}')
def process_geo_index(self): def process_geo_index(self):
pass geo_index = self.initialize_layer(self.geoindex, 'GeoIndex')
print(f'Data Count of the GeoIndex layer: {geo_index.data_count}')
geo_index.create_spatial_index()
geo_index.fix_geometries(self.output_paths['Fixed GeoIndex'])
geo_index_fixed = \
self.initialize_layer(self.output_paths['Fixed GeoIndex'],
'Fixed GeoIndex')
geo_index_fixed.create_spatial_index()
print(f'Data Count of the GeoIndex layer ({geo_index_fixed.layer_name})'
f'after fixing geometries: {geo_index_fixed.layer.featureCount()}')
geo_index_fixed.clip_layer(self.montreal_boundary,
self.output_paths['Clipped Fixed GeoIndex'])
geo_index_clipped = \
self.initialize_layer(self.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'({geo_index_clipped.layer_name}) after clipping it '
f'based on the Montreal Boundary layer: '
f'{geo_index_clipped.layer.featureCount()}')
def process_property_assesment(self): def process_property_assesment(self):
pass pass