0

Is it possible (and if yes then how or has this been done) to convert v.net.spanningtree in to a QGIS/python (custom) script that can be accessed in the QGIS graphical modeler in a way that GRASS is not needed to be installed?

Use case:
I have built a model in the QGIS graphical modeler that uses the GRASS spanning tree algorithim, however, I would like this model to work on other people's computers who may not be able to easily install GRASS (or access its plugins through QGIS GUI) so they can use the model, as well as hopefully we could install it on android tablets (that may not have or even be able to install GRASS?).

This model (which currently collates about 50 algorithms which I hope I can simplify a bit!) is currently working well on my desktop but ultimately hoping to get it working on android tablets to be used in the field (though haven't tested QGIS on android yet so not sure of any limitations that may be encountered with that ... though hopefully soon!).

Notes:

The QGIS plugin "Reconstruct Line" (https://github.com/nextgis/ReconstructLine), using the "Insert multiple lines" functionality, also essentially achieves the same result as the GRASS v.net.spanningtree if this is any help as perhaps it would be easier to make this availiable in the graphical modeller/as a custom script.

I am using QGIS 2.16.2 on Windows 7 (but would ultimately need a solution that is workable on other systems)

If the only solution is to create a script from scratch it might be a bit beyond my capabilities at the moment. I do not have python/scripting skills but may be able to work my way through using trial and error in some cases if any proposed solution is close to the mark and not too complex to follow.

  • I included the sub questions as I thought answering them would potentially be workaround solutions to answering the overal question. Should I post them as seperate questions? – guestagain Sep 22 '16 at 7:12
1

Grass standalone
I would say it would be difficult to use v.net.spanningtree (or any other) without grass or at least a truncated version of it.

Indeed, if you download the source code ( https://grass.osgeo.org/download/software/sources/ ) and check v.net.spanningtree/main.c you see the following:

#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include <grass/neta.h>

Calling plugin from modeler
According to various sources, including this: Access all plugin from QGIS Modeler (Sextante) the modeler seems to be restricted to processing functions and script, and does not accept the use of plugins.

Solution to work out
The only solution therefore seems to create a script, that would call the necessary plugin and run it.
You can find examples in different places such as:
How to use QGIS Zonal Stats Plugin from Python Console?
How to use the MMQGIS plugin through the Python console?
How to call the interpolation plugin from the python console?
Cheers,

  • hmmm, thanks for the note @Victor. I think that's suggesting I may be better off asking if the QGIS plugin "Reconstruct Line" (github.com/nextgis/ReconstructLine), or similar automated process to GRASS's v.spanningtree, would be availiable to the graphical modeler? – guestagain Sep 22 '16 at 9:55
  • 1
    This seems to indicate that it is not that easy: gis.stackexchange.com/questions/73835/… Let's be clear that I am not sure about my answer above. Hopefully someone with programming skills can validate or invalidate my conjecture. – Victor Sep 22 '16 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.