[GRASS-user] seeking advice for additional scripts

Hi List,

I'm seeking advice on best-practices for where/how to add minor custom scripts to GRASS.

For example, I'd like be able to run 1 command and see a raster with legend. This is almost supported by "d.rast.leg", but it crashes if no monitors have been started. So I'd like to add "d.rast.legend", or "my.rast.leg" that starts a monitor if needed, then calls "d.rast.leg"

Where should this script go, and do you have advice on what language to use? My first thought was to make it a bash shell script and put it in ~/bin/ or ~/bin/grass/ and add that to GRASS_ADDON_PATH. Is there standard location for things like this?

And should it be in Python or bash? Seems like either works right now, but will bash be phased out in the future?

Thanks,

  -k.

Hi,

2016-04-05 20:59 GMT+02:00 Ken Mankoff <mankoff@gmail.com>:

Where should this script go, and do you have advice on what language to use? My first thought was to make it a bash shell script and put it in ~/bin/ or ~/bin/grass/ and add that to GRASS_ADDON_PATH. Is there standard location for things like this?

I would choose ~/bin/grass (~/bin is not good choice because than your
scripts will be in default PATH, so visible also outside of GRASS).

And should it be in Python or bash? Seems like either works right now, but will bash be phased out in the future?

For simple/quick stuff I would use Bash. For the rest (more complex
stuff, anything you want to publish as addons) I would choose Python.
Please note that GRASS 7 supports only Python for Addons.

Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa

On Tue, Apr 5, 2016 at 9:06 PM, Martin Landa <landa.martin@gmail.com> wrote:

Hi,

2016-04-05 20:59 GMT+02:00 Ken Mankoff <mankoff@gmail.com>:
> Where should this script go, and do you have advice on what language to
use? My first thought was to make it a bash shell script and put it in
~/bin/ or ~/bin/grass/ and add that to GRASS_ADDON_PATH. Is there standard
location for things like this?

I would choose ~/bin/grass (~/bin is not good choice because than your
scripts will be in default PATH, so visible also outside of GRASS).

If you are on Linux, I think you can copy your script to the same folder
that is used by g.extension to install addon scripts. For me that is
~/.grass7/addons/scripts , but I assume that is the same on most Linux
systems.

> And should it be in Python or bash? Seems like either works right now,
but will bash be phased out in the future?

From what I understand, there are no plans to phase out bash, so you could

use that if that works best for you. For sharing with others python is
probably the better choice, especially because of compatibility issues on
Windows.

For simple/quick stuff I would use Bash. For the rest (more complex
stuff, anything you want to publish as addons) I would choose Python.
Please note that GRASS 7 supports only Python for Addons.

That depends how you define addons. You cannot install shell scripts with
g.extension, but if you put them in ~/.grass7/addons/scripts they should
work fine. Having said that, Python would still be the better option.

Ma

--
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi Martin and Paulo,

I hadn't considered others might uses these scripts, but I guess it is worth treating them as an extensions/addons as they might be generally useful.

In this case, GRASS seems to have a fairly flat namespace. Do you recommend keeping the grass naming scheme, or should I name my scripts, for example, "kdm.d.rast.leg" (my initials are kdm) to reduce the chance of collision?

  -k.

On Wed, Apr 6, 2016 at 8:44 AM, Ken Mankoff <mankoff@gmail.com> wrote:

Hi Martin and Paulo,

I hadn't considered others might uses these scripts, but I guess it is worth treating them as an extensions/addons as they might be generally useful.

In this case, GRASS seems to have a fairly flat namespace. Do you recommend keeping the grass naming scheme, or should I name my scripts, for example, "kdm.d.rast.leg" (my initials are kdm) to reduce the chance of collision?

rather than initials the functionality should be reflected in the
name, although that might be difficult. I would put it in the end like
d.rast.leg.kdm or d.rast.legkdm

Anna

  -k.
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

On 2016-04-06 at 10:50, Anna Petrášová <kratochanna@gmail.com> wrote:

rather than initials the functionality should be reflected in the
name, although that might be difficult. I would put it in the end like
d.rast.leg.kdm or d.rast.legkdm

Good advice. Thanks. Done: https://github.com/mankoff/grass_addons

  -k.
  

On Wed, Apr 6, 2016 at 12:08 PM, Ken Mankoff <mankoff@gmail.com> wrote:

On 2016-04-06 at 10:50, Anna Petrášová <kratochanna@gmail.com> wrote:

rather than initials the functionality should be reflected in the
name, although that might be difficult. I would put it in the end like
d.rast.leg.kdm or d.rast.legkdm

Good advice. Thanks. Done: https://github.com/mankoff/grass_addons

BTW, g.extension in grass 7.1 supports installing python addons from
github (Linux and Mac only). But you have to provide Makefile and
manual page - basically the same structure as addons in official
repository have.

Anna

  -k.