2

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\985円c82bb1ac3468f9a8d49b49ad53def\\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?

asked Jan 25, 2017 at 11:33
3
  • Does an output appear if you replace runalg with runandload? Commented Jan 25, 2017 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 Commented Jan 25, 2017 at 11:49
  • The error from qgis log: "Could not load layer: ..." There is nothing relevant in the Processing > History log Commented Jan 25, 2017 at 11:52

1 Answer 1

3

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)
answered Jan 25, 2017 at 12:20
6
  • 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. Commented Jan 25, 2017 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. Commented Jan 25, 2017 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. Commented Jan 25, 2017 at 14:43
  • @eglatorre - Most welcome and please do! You could ask a new question and see if others know of a solution :) Commented Jan 25, 2017 at 14:47
  • I asked here gis.stackexchange.com/questions/225827/… Commented Jan 25, 2017 at 16:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.