1

I have a QGIS plugin that runs the v.clean algorithm two times (first time snap, second break) on a chosen layer:

    output = self.dlg.directory.text()

    params_snap = {
        'input' : input,
        'type' : 1,
        'tool' : 1,
        'threshold' : 0.000095,
        'output': output,
        'error' : error,
        '--overwrite': True,
        'GRASS_OUTPUT_TYPE_PARAMETER': 2
    }
    processing.run('grass7:v.clean', params_snap)

    params_break = {
        'input': output,
        'type': 1,
        'tool': 0,
        'threshold': 0.1,
        '-c': True,
        'output': output,
        'error': error,
        '--overwrite': True,
        'GRASS_OUTPUT_TYPE_PARAMETER': 2
    }
    processing.runAndLoadResults('grass7:v.clean', params_break)

My problem is that after running snap, the created output file is not overwritten. runAndLoadResults of the break algorithm loads the output file as expected, but without broken lines. So only snap was applied. Since --overwrite is True it should work, or do I miss something?

If I choose another output file for the break algorithm everything runs perfect, so the problem is not the algorithm itself.

As stated in my other question here, a temporary output is not possible for Grass algorithms and therefore no solution.

EDIT: The processing log messages print an error:

2019-01-30T11:59:16     INFO    C:\Windows\System32>v.out.ogr -c type="line"
input="output6c3d7544cb524a2486d97aca71a41bc4" output="C:\Users\USER
\Desktop\test.gpkg" format="GPKG" --overwrite
2019-01-30T11:59:16     CRITICAL    ERROR 1: A file system object called  
'C:\Users\USER\Desktop\test.gpkg' already exists.

So Grass recognizes overwrite, but it does not work. Is this the wrong command, for what I try to achieve? The algorithm help (processing.algorithmHelp("grass7:v.clean")) gives no information about overwrites. I got the information from the v.clean manual.

  • I do not know about coding yet, and there are many users who do. But I can offer you my perspective as a user. If I want to run a similar command in GRASS, I get the same error. The option to overwrite, for me, means that the output file can be pre-existing, but not that it is in use by the same command. I can not give a command the same input file as output. On the other hand, I can give it a pre-existing file and overwrite it, as long as it is not the same input file. – Gabriel De Luca Jan 31 at 5:19
2

You are assigning the same file for the input and output parameters.

If I try to run a similar command in the GRASS v.clean algorithm from QGIS, I get the same error.

The overwrite option means that the output file can pre-exist, and it works fine as long as the file itself is not open or in use by the same algorithm.

  • I'm not sure I'm using the right technical words in my answer. Editions to my answer or more detailed answers from more experienced users are welcome. – Gabriel De Luca Jan 31 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.