[Qgis-developer] Adding grass commands to the processing toolbox

Olivier Dalang olivier.dalang at gmail.com
Wed Apr 1 07:26:47 PDT 2015


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 <olivier.dalang at gmail.com>:

> 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 at anita_000 output=centrality
> degree=degree closeness=closeness betweenness=betweenness
> eigenvector=eigenvector
> (found here: http://planet.qgis.org/planet/tag/gis%20analysis/ , thanks
> Anita)
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150401/1f080670/attachment.html>


More information about the Qgis-developer mailing list