I am running a grass tool from the python console to obtain a buffer from a vector polygon layer. But the result shapefile is not being created.

Running the same tool manually from the Processing tools as a GUI works just fine.

I am using Windows-QGIS 2.14.11-GRASS 7.2.0.

The vector layer is in variable part1 and the result should be going to a temporary folder (output is specified as None to the script). The call to the tool is:

result = processing.runalg('grass:v.buffer.distance', part1,'10','0.01',True,True, extent, -1.0, 0.0001, 0, None)

The command runs without problems and the variable result contains the name of the processing, the name to the result file:

{'result': u'C:\\Users\\username\\AppData\\Local\\Temp\\processing1dbc8a694a98406aa1f7656068b6f239\\985c82bb1ac3468f9a8d49b49ad53def\\output.shp'}

But there are no files there.

The same problem happes at least with grass:v.clean.

Anyone else has this problem?

Since the tool works when run manually from Processing as a GUI tool, is there a bug somewhere where in the python scripts?

  • Does an output appear if you replace runalg with runandload? – Joseph Jan 25 '17 at 11:36
  • I get the error: The following layers were not correctly generated. Cleaned Errors You can check the log messages to find more information about the execution of the algorithm – eglatorre Jan 25 '17 at 11:49
  • The error from qgis log: "Could not load layer: ..." There is nothing relevant in the Processing > History log – eglatorre Jan 25 '17 at 11:52

If you're using GRASS 7, you will need to use grass7:v.buffer.distance instead of grass:v.buffer.distance.

So try using the following:

result = processing.runalg('grass7:v.buffer.distance', part1,'10','0.01',True,True, extent, -1.0, 0.0001, 0, None)
  • 1
    It worked perfectlty. @Joseph Is there a way to know/impose what grass version is running in the python console or inside the plugins? I tested that running QGIS from the QGIS 2.14 start icon (not the "with GRASS 7.2.0"), still requires grass7:v.buffer.distance to work. – eglatorre Jan 25 '17 at 14:03
  • @eglatorre - Hmm couldn't find anything about obtaining the GRASS version from within the Processing plugin (although I could have missed it). I think most GRASS modules have been ported to GRASS7 in the recent QGIS versions. – Joseph Jan 25 '17 at 14:25
  • ok, thanks a lot for helping with this. I will keep an eye on this and let you know if I find a way to check the grass version. – eglatorre Jan 25 '17 at 14:43
  • @eglatorre - Most welcome and please do! You could ask a new question and see if others know of a solution :) – Joseph Jan 25 '17 at 14:47
  • I asked here gis.stackexchange.com/questions/225827/… – eglatorre Jan 25 '17 at 16:15

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.