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?
1 Answer 1
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)
-
1It 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– eglatorre2017年01月25日 14:03:51 +00:00Commented 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.Joseph– Joseph2017年01月25日 14:25:13 +00:00Commented 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.eglatorre– eglatorre2017年01月25日 14:43:23 +00:00Commented 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 :)Joseph– Joseph2017年01月25日 14:47:04 +00:00Commented Jan 25, 2017 at 14:47
-
I asked here gis.stackexchange.com/questions/225827/…eglatorre– eglatorre2017年01月25日 16:15:40 +00:00Commented Jan 25, 2017 at 16:15
Explore related questions
See similar questions with these tags.
runalg
withrunandload
?