I have a QGIS plugin that tries to call the v.clean
algorithm multiple times in a row and use the same output file each time the algorithm runs through. But even though I set the --overwrite
parameter to true (as found in the grass manual), the output can't be overwritten and instead I get the error
ERROR 1: A file system object called 'C:\Users\...\Desktop\output.gpkg' already exists.
in the QGIS log. I can still run the plugin, but only the snap
algorithm of the following code will be applied to my line layer:
output = self.dlg.directory.text()
params_snap = {
'input' : input_2,
'type' : 1,
'tool' : 1,
'threshold' : 0.000095,
'output': output,
'error' : 'memory:',
'GRASS_OUTPUT_TYPE_PARAMETER': 2
}
processing.run('grass7:v.clean', params_snap)
params_break = {
'input': input_2,
'type': 1,
'tool': 0,
'threshold': 0.1,
'-c': True,
'output': output,
'error': 'memory:',
'--overwrite': True,
'GRASS_OUTPUT_TYPE_PARAMETER': 2
}
processing.runAndLoadResults('grass7:v.clean', params_break)
The path and name of the ouput are from a QFileDialog. If the information is needed: The input file is a temporary file.
If I set a different output file for each part of the processing the code runs fine and without errors, but since I will use more than only two algorithms creating and deleting files over and over again will just slow the plugin down.
I use the current QGIS LTR 3.4.
--overwrite
. I suggest running this tool once using the QGis interface and then looking at the processing history to find out exactly how QGis runs this tool--ouverwrite
and-o
at the same time, but neither of them, nor both of them work.