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 <[email protected]> On Behalf Of Cam Morlus
Sent: torsdag 14. januar 2021 21:23
To: [email protected]
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
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to