Add scrub mtl class & add fix geometries
This commit is contained in:
parent
c6b7972de5
commit
109c3cba61
|
@ -26,26 +26,40 @@ class ScrubLayer:
|
||||||
QgsProject.instance().addMapLayer(the_layer)
|
QgsProject.instance().addMapLayer(the_layer)
|
||||||
return the_layer
|
return the_layer
|
||||||
|
|
||||||
|
def fix_geometries(self, fixed_layer):
|
||||||
|
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||||
|
fix_geometries_params = {
|
||||||
|
'INPUT': self.layer,
|
||||||
|
'METHOD': 0,
|
||||||
|
'OUTPUT': fixed_layer
|
||||||
|
}
|
||||||
|
processing.run("native:fixgeometries", fix_geometries_params)
|
||||||
|
|
||||||
def create_spatial_index(self):
|
def create_spatial_index(self):
|
||||||
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||||
create_spatial_index_params = {
|
create_spatial_index_params = {
|
||||||
'INPUT': self.layer_path,
|
'INPUT': self.layer,
|
||||||
'OUTPUT': 'Output'
|
'OUTPUT': 'Output'
|
||||||
}
|
}
|
||||||
processing.run("native:createspatialindex", create_spatial_index_params)
|
processing.run("native:createspatialindex", create_spatial_index_params)
|
||||||
|
print(f'Creating spatial index for {self.layer_name} is completed.')
|
||||||
|
|
||||||
|
def clip_layer(self, overlay_layer, clipped_layer):
|
||||||
|
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
|
||||||
|
clip_layer_params = {
|
||||||
|
'INPUT': self.layer_path,
|
||||||
|
'OVERLAY': overlay_layer,
|
||||||
|
'FILTER_EXPRESSION': '',
|
||||||
|
'FILTER_EXTENT': None,
|
||||||
|
'OUTPUT': clipped_layer
|
||||||
|
}
|
||||||
|
processing.run("native:clip", clip_layer_params)
|
||||||
|
print(f'Clipping of {self.layer_name} is completed.')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cleanup():
|
def cleanup():
|
||||||
QgsApplication.exitQgis()
|
QgsApplication.exitQgis()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app_path = 'C:/Program Files/QGIS 3.34.1/apps/qgis'
|
|
||||||
new_path = 'C:/Users/a_adli/PycharmProjects/hydroquebec_archetype_gispy/' \
|
|
||||||
'data/test_data/test_input/nrcan_north/nrcan_north.shp'
|
|
||||||
data_layer_name = 'nrcan_north'
|
|
||||||
handle_layer = ScrubLayer(app_path, new_path, data_layer_name)
|
|
||||||
# print(handle_layer.layer.featureCount())
|
|
||||||
handle_layer.create_spatial_index()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
32
scrub_mtl_class.py
Normal file
32
scrub_mtl_class.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from scrub_layer_class import *
|
||||||
|
|
||||||
|
|
||||||
|
class ScrubMTL:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def define_input_paths(self):
|
||||||
|
"""Can be a part of the constructor"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def generate_output_paths(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def initialize_layer(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def process_nrcan(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def process_geo_index(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def process_property_assesment(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def remove_redundant_fields(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def remove_records_by_area(self, area_limitation):
|
||||||
|
"""Area limitation can be assigned in the constructor"""
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user