2

I try to run a QGIS plugin in QGIS 3.4 that uses processing to execute algorithms in a row:

    params_snap = {
        'input' : input,
        'type' : 1,
        'tool' : 1,
        'threshold' : 0.000095,
        'output': 'memory:',
        'error' : error,
        'GRASS_OUTPUT_TYPE_PARAMETER' : 2
    }

    snap = processing.runAndLoadResults('grass7:v.clean', params_snap)

    params_break = {
        'input': snap['output'],
        'type': 1,
        'tool': 0,
        'threshold': 0,
        'output': output,
        'error': error,
        'GRASS_OUTPUT_TYPE_PARAMETER': 2
    }

    processing.runAndLoadResults('grass7:v.clean', params_break)

First the v.clean snap algorithm runs. The result is saved in a temporary output layer. This algorithm work without any problems. Afterwards I try to run v.clean break and the input should be the temporarily saved output layer of the first algorithm. But I get the error: Could not load source layer for input: memory: not found.

If I use a filepath instead of 'memory:' in the first output everything works fine and the second algorithm can access the first algorithms output. So I assume that the problem is the 'memory:' statement, but all the sources I found tell to use it.

Edit:

I checked the temporary folder (C:\Users\USER\AppData\Local\Temp\processing_83c42fa467d2461eb67590c719fc22aa\grassdata\temp_location\PERMANENT\vector) and the layer gets successfully created when I run the code. But since it is not located directly in the path C:\Users\USER\AppData\Local\Temp\ I wonder if the path the temporary files are created in is the right one?

  • Have you tried assigning a name for the memory layer? – bugmenot123 Jan 28 at 13:13
  • Yes, same error. 'memory: name' not found. – gHupf Jan 28 at 13:19
5

The grass provider does not support QGIS memory layers, so you'll need to give it a path to a real location it can store the temporary result as.

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.