[GRASS-user] How to create a GRASS addon that returns something when using read_command()

Cam Morlus cam.morlus at gmail.com
Fri Jan 15 01:52:34 PST 2021


Hi Stefan,

Thank you very much for your answer and the documentation! I was able to
write my addon thanks to it :)

Have a nice day,

Camille

Le jeu. 14 janv. 2021 à 21:39, Stefan Blumentrath <
Stefan.Blumentrath at nina.no> a écrit :

> Hi Camille,
>
>
>
> Great resources to start with are:
>
> wenzeslaus/python-grass-addon: How to write a Python GRASS GIS 7 addon
> (github.com) <https://github.com/wenzeslaus/python-grass-addon>
>
> and
>
> wenzeslaus/r.example.plus: An example of a GRASS GIS module for processing
> rasters (github.com) <https://github.com/wenzeslaus/r.example.plus>
>
>
>
> If you want your module to return not maps or tables but output on stdout
> (what read_command() captures), just use the print() function in python.
>
>
>
> Hope that helps to get started!?
>
>
>
> If there is a module that has a UI that could be a good template for what
> you want to do, you can use e.g. “r.info –script” to get a script
> template for the UI and general content.
>
>
>
> Cheers
>
> Stefan
>
>
>
>
>
> *From:* grass-user <grass-user-bounces at lists.osgeo.org> *On Behalf Of *Cam
> Morlus
> *Sent:* torsdag 14. januar 2021 21:23
> *To:* grass-user at lists.osgeo.org
> *Subject:* [GRASS-user] How to create a GRASS addon that returns
> something when using read_command()
>
>
>
> Dear All,
>
>
>
> I am using grass 7.8.4. I'm calling commands externally using the Grass
> Python Scripting Library in Python. I wanted to know when you create an
> addon in python how to end the addon script so that when you call that
> addon with read_command() it returns something. I would like to have
> something similar to what happens when calling read_command(g.gisenv) which
> returns the grass variables settings so that you can store them into a
> variable.
>
>
>
> Thank you in advance for your answer.
>
>
>
> Best,
>
>
>
> Camille Morlighem
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20210115/90ec11da/attachment-0001.html>


More information about the grass-user mailing list