Saturday, 17 February 2018

qgis - Missing the results from grass tools when used in python console


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?




Answer



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)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...