[GRASS-dev] Programmatically obtain GRASS colour ramps in Python

Hi all,

I am trying to write a little Python extension wrapping r.color to use
different kind of strecthes,

It should be pretty simple, basically just builkding rules on-the-fly
and pass them to r.color. But I can't quite seem how to retrieve the
GRASS color ramps details to create my ruleset.

Is there any portable way to actually to actually passthe name of a
GRASS color ramp, and get the details (colours) of that colour ramp?

Cheers,

Pierre

On Mon, Sep 17, 2018 at 4:17 AM Pierre Roudier <pierre.roudier@gmail.com> wrote:

Hi all,

I am trying to write a little Python extension wrapping r.color to use
different kind of strecthes,

It should be pretty simple, basically just builkding rules on-the-fly
and pass them to r.color. But I can't quite seem how to retrieve the
GRASS color ramps details to create my ruleset.

Is there any portable way to actually to actually passthe name of a
GRASS color ramp, and get the details (colours) of that colour ramp?

Maybe you can find some code here:

gui/wxpython/modules/colorrules.py

best
Markus

r.colors manual says color ramps are saved in:
$GISBASE/etc/colors/<name>, so values could be read from there, I guess.

And the parser can give you GUI access to the rules names with the
G_OPT_M_COLR option:
https://grass.osgeo.org/grass77/manuals/parser_standard_options.html

Cheers
Stefan

-----Original Message-----
From: grass-dev <grass-dev-bounces@lists.osgeo.org> On Behalf Of Markus Neteler
Sent: mandag 17. september 2018 20:15
To: Pierre Roudier <pierre.roudier@gmail.com>
Cc: GRASS developers list <grass-dev@lists.osgeo.org>
Subject: Re: [GRASS-dev] Programmatically obtain GRASS colour ramps in Python

On Mon, Sep 17, 2018 at 4:17 AM Pierre Roudier <pierre.roudier@gmail.com> wrote:

Hi all,

I am trying to write a little Python extension wrapping r.color to use
different kind of strecthes,

It should be pretty simple, basically just builkding rules on-the-fly
and pass them to r.color. But I can't quite seem how to retrieve the
GRASS color ramps details to create my ruleset.

Is there any portable way to actually to actually passthe name of a
GRASS color ramp, and get the details (colours) of that colour ramp?

Maybe you can find some code here:

gui/wxpython/modules/colorrules.py

best
Markus
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev

Hi Pierre,

If you would turn this into a add-on module it could eventually became the portable way to do that… Having this functionality makes sense.

Vaclav

On Mon, Sep 17, 2018 at 3:28 PM Stefan Blumentrath <Stefan.Blumentrath@nina.no> wrote:

r.colors manual says color ramps are saved in:
$GISBASE/etc/colors/, so values could be read from there, I guess.

And the parser can give you GUI access to the rules names with the
G_OPT_M_COLR option:
https://grass.osgeo.org/grass77/manuals/parser_standard_options.html

Cheers
Stefan

-----Original Message-----
From: grass-dev <grass-dev-bounces@lists.osgeo.org> On Behalf Of Markus Neteler
Sent: mandag 17. september 2018 20:15
To: Pierre Roudier <pierre.roudier@gmail.com>
Cc: GRASS developers list <grass-dev@lists.osgeo.org>
Subject: Re: [GRASS-dev] Programmatically obtain GRASS colour ramps in Python

On Mon, Sep 17, 2018 at 4:17 AM Pierre Roudier <pierre.roudier@gmail.com> wrote:

Hi all,

I am trying to write a little Python extension wrapping r.color to use
different kind of strecthes,

It should be pretty simple, basically just builkding rules on-the-fly
and pass them to r.color. But I can’t quite seem how to retrieve the
GRASS color ramps details to create my ruleset.

Is there any portable way to actually to actually passthe name of a
GRASS color ramp, and get the details (colours) of that colour ramp?

Maybe you can find some code here:

gui/wxpython/modules/colorrules.py

best
Markus


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev


grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev