Adding grass commands to the processing toolbox

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding grass commands to the processing toolbox

olivier
Dear list,

How can I use a GRASS function from within QGIS if it's not in the toolbox ?

Ideally, I'd like a GUI solution. But actually I wasn't even able to find how to use it in command line (I don't know anything of grass, only used it through the processing toolbox for now).

I'm trying to use this function:
v.net.centrality -a input=streets@anita_000 output=centrality degree=degree closeness=closeness betweenness=betweenness eigenvector=eigenvector

This is how far I got:

.qgis2\processing\scripts\betweennessCentrality.py
 
##network=vector
##output=output vector
import grass.script as grass
grass.run_command("v.net.centrality", flags='a', input=network, output=output, degree='degree', closeness='closeness', betweenness='betweenness', eigenvector='eigenvector')

But I get an error when I run the algorithm (the gui loads nicely):
No module named grass.script See log for more details


Any help would be greatly appreciated !

Best,

Olivier


_______________________________________________
Qgis-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-user
Reply | Threaded
Open this post in threaded view
|

Re: Adding grass commands to the processing toolbox

olivier
Hi again !

I'm crossposting to qgis-dev since it's becoming more of a dev question...

I found a way to make it work on QGIS 2.8 64 bits (windows).

I've added this file  OSGeo4W64\apps\qgis\python\plugins\processing\algs\grass\description\v.net.centrality.txt  with this content :
v.net.centrality
v.net.centrality - Toolset for computing centralities
Vector (v.*)
ParameterVector|input|Neworklayer|-1|False
ParameterString|betweenness|Betweenness field name|betweenness
ParameterBoolean|-a|-a|True
OutputVector|output|Output

And now I've the function right in QGIS's toolbox, and it works perfectly !

However, this doesn't seem to work on Mac (I put the file in the corresponding folder of QGIS.app, but the tool doesn't appear in the processing toolbox), any idea why ?
Or is it globally not the way to go (it seems a bit dirty to extend the toolbox by creating new files in the application folder) ?

Best,

Olivier

2015-04-01 13:05 GMT+02:00 Olivier Dalang <[hidden email]>:
Dear list,

How can I use a GRASS function from within QGIS if it's not in the toolbox ?

Ideally, I'd like a GUI solution. But actually I wasn't even able to find how to use it in command line (I don't know anything of grass, only used it through the processing toolbox for now).

I'm trying to use this function:
v.net.centrality -a input=streets@anita_000 output=centrality degree=degree closeness=closeness betweenness=betweenness eigenvector=eigenvector

This is how far I got:

.qgis2\processing\scripts\betweennessCentrality.py
 
##network=vector
##output=output vector
import grass.script as grass
grass.run_command("v.net.centrality", flags='a', input=network, output=output, degree='degree', closeness='closeness', betweenness='betweenness', eigenvector='eigenvector')

But I get an error when I run the algorithm (the gui loads nicely):
No module named grass.script See log for more details


Any help would be greatly appreciated !

Best,

Olivier



_______________________________________________
Qgis-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-user