Index de l'article

Miscellaneous about processing

Fix invalid geometry (and register the output to use it later)

Here we register the output with the name MyFixedLayer. So we can use it later.

alg_params = {
    'INPUT':'E:\\Downloads\\MyLayer.shp',
    'METHOD':1,
    'OUTPUT':'E:\\Downloads\\MyFixedLayer.shp'
}
outputs['MyFixedLayer'] = processing.run('native:fixgeometries', alg_params, context=context)

Fix invalid geometry (from a previous output registered)

alg_params = {
'INPUT': outputs['MyPreviousOutput']['OUTPUT'],
'METHOD':1,
'OUTPUT': QgsProcessing.TEMPORARY_OUTPUT
}
outputs['MyNewOutput'] = processing.run('native:fixgeometries', alg_params, context=context)