[GRASS-dev] Access to GRASS GIS addons

Stefan Blumentrath Stefan.Blumentrath at nina.no
Fri Oct 12 02:00:07 PDT 2018


Dear Nikos and others,

First of all, we have to clarify if you:
a) want a solution that does not require a GRASS database (meaning a Processing like approach) or
b) if an existing GRASS database is acceptable as a requirement to run your addon

If the answer is a), the Situation (in QGIS 3) regarding GRASS integration in QGIS is indeed far from ideal.
In order to change that, a bigger effort seems necessary (as envisioned in the GSoC).

As a workaround for a) you could write a Processing Python script as a wrapper that uses the grass --exec functionality with a temporary GRASS DB and:
1) installs the addon if it does not exist
2) takes QGIS layers (and additional parameters) as input, imports the layers to the temporary GRASS DB, runs your addon and exports the results

The QGIS-GRASS-plugin seems to work also in QGIS 3. It is fully possible to get addons into the GRASS-plugin. Yet, same as for processing, you have to manipulate the installation (which probably not all users would be allowed and able to do).

In any case, with current solutions you will have to recreate the UI in QGIS.

Cheers
Stefan



-----Original Message-----
From: grass-dev <grass-dev-bounces at lists.osgeo.org> On Behalf Of Nikos Alexandris
Sent: fredag 12. oktober 2018 02:31
To: Ondřej Pešek <pesej.ondrek at gmail.com>
Cc: GRASS developers list <grass-dev at lists.osgeo.org>
Subject: Re: [GRASS-dev] Access to GRASS GIS addons

* Ondřej Pešek <pesej.ondrek at gmail.com> [2018-10-11 20:20:40 +0200]:

>čt 11. 10. 2018 v 17:24 odesílatel Vaclav Petras <wenzeslaus at gmail.com>
>napsal:
>
>> A 2016 GSoC project took different approach which could be reused in 
>> QGIS independently from the current GRASS Plugin or Processing plugin 
>> approaches. This is a good base for future work, perhaps even for 
>> auto-generating the files needed for GRASS plugin or Processing plugin.
>>
>> https://trac.osgeo.org/grass/wiki/GSoC/2016/PyQtGUI
>>
>
>
>If you start QGIS from the GRASS GIS shell, then you can use a module 
>g.pyqt from the above-mentioned GSoC project and parse the name of the 
>AddOn as a parameter. It will generate the fully-working GUI for you.
>
>So if you want to create a QGIS plugin and don't want to create the GUI 
>from scratch, then you can call something like `g.pyqt r.estimap` after 
>clicking on the icon of the plugin and it's done. However, it will 
>still work just with maps in GRASS, it will not import them into QGIS 
>or something, and there is also this strange thing about running QGIS 
>from the GRASS GIS shell.
>
>And I didn't touch the code for some time, so there are still some 
>places which should be improved. But it should be working if you have 
>your AddOn installed in GRASS.
>
>PS: I believe that the code can be also re-written to generate the QGIS 
>plugin GUI without all those strange necessities without so much work, 
>but unfortunately I don't have enough time to do it in the near future.

Thank you Ondřej, also through the list.

(@all: we are not far away with Ondřej these days and he already helped me, i.e. took time earlier in August and explained how it works under Linux, and during the last days we did make it work on-site--I am yet to try it on a Windows box though.)

However, I try to collect as much information as I can about it in order to find the best solution for Windows users.  And I think it is a question that is of interest for all of us, users of GRASS GIS and QGIS, regardless of the OS.


Following options:

1. PyQTGUI

- Works under Linux for QGIS 2.x,
- Requires softlinking the Addon's directory which should reside inside
  the PyQTGUI (and possible named without a dot) to QGIS' plugins
  directory -- I guess this can be scripted
- Would require to ship the Addon with the complete PyQTGUI
- Yet to test under Windows

2. PyQGIS?

3. QGIS GRASS Plugin

4. QGIS Processing -- see also: https://gis.stackexchange.com/a/223770/5256

5. Ondřej suggested also another possibility: if an Addon is installed, maybe then, inside QGIS: GRASS GIS Plugin > GRASS GIS shell > run `r.<addon> --ui` would suffice?

Any Windows user possibly to try this last option?


Note, there is an "answer" by @Vaclav at https://gis.stackexchange.com/a/173536/5256, which is rather discouraging for GRASS GIS Addons through QGIS. I hope we can update it.

Nikos


More information about the grass-dev mailing list