1

I am creating a Python script in QGIS 3 and I want to use the processing module. I want to transform my raster file to a vector file with the GRASS algorithm r.to.vect. My problem here is that the output I am getting is always empty. The way I am running the algorithm looks like this:

    param = {"input": path_to_some_raster_file,
             "type": 2,
             "output": some_tmp_file,
             'GRASS_OUTPUT_TYPE_PARAMETER': 0
             }

    vector = processing.run('grass7:r.to.vect', param)

But if I use the same parameters in the processing toolbox then the desired output is generated. What am I doing wrong with my Python attempt?

  • From the menubar, go to Processing > History. This will show you how the parameters for the tool should be used when running it from the console or script. – Joseph Feb 19 at 15:59
  • That still doesn't help me with my problem. I even copied the whole command from the history and run it in the qgis console and the result remains the same unfortunately.... – Blinxen Feb 19 at 16:10
  • I use version 3.4.4 – Blinxen Feb 22 at 11:55
  • 1
    Empty as in you receive an output but it contains no data or you do not receive any output (in which case maybe use processing.runAndLoadResults() instead of processing.run())? – Joseph Feb 22 at 12:05
  • Empty as in an output which contains no data. If I use processing.runAndLoadResults() then I get a QgsProcessingOutputLayerDefinition object. – Blinxen Feb 22 at 13:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.