[GRASS-dev] [bug #5243] (grass) d.vect: better random color generation

this bug's URL: http://intevation.de/rt/webrt?serial_num=5243
-------------------------------------------------------------------------

[wish]

Hi,

currently "d.vect -c" random colors is limited to 16 colors, which do
not rotate between calls. (you get the same colors every time, d.redraw
doesn't help if you don't like the results)

see display/d.vect/plot.h for current candidates.

I suggest using random color code from lib/gis/color_rand.c to do a
better job. It seems to work pretty well.

or if that won't work (too many cats to store RGB values) start with
random seed and calculate R,G,B values by some mathematical function
which will give the same answers for those 3 variables within the module
run.

thanks,
Hamish

--- Headers Follow ---

From hamish_nospam@yahoo.com Sun Oct 29 08:12:05 2006

Return-Path: <hamish_nospam@yahoo.com>
Delivered-To: grass-bugs@lists.intevation.de
Received: from kolab.intevation.de (aktaia [212.95.126.10])
  by lists.intevation.de (Postfix) with ESMTP id D9B871006AB
  for <grass-bugs@lists.intevation.de>; Sun, 29 Oct 2006 08:12:05 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
  by kolab.intevation.de (Postfix) with ESMTP id BFDC41B1A17
  for <grass-bugs@lists.intevation.de>; Sun, 29 Oct 2006 08:12:05 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
  by kolab.intevation.de (Postfix) with ESMTP id A690B1AFCC3
  for <grass-bugs@lists.intevation.de>; Sun, 29 Oct 2006 08:12:05 +0100 (CET)
Received: from mailhub1.otago.ac.nz (mailhub1.otago.ac.nz [139.80.64.218])
  by kolab.intevation.de (Postfix) with ESMTP id B66381AD41A
  for <grass-bugs@intevation.de>; Sun, 29 Oct 2006 08:10:31 +0100 (CET)
Received: from galadriel.otago.ac.nz (galadriel.otago.ac.nz [139.80.64.213])
  by mailhub1.otago.ac.nz (8.13.6/8.13.6) with ESMTP id k9T7AQP8003694
  for <grass-bugs@intevation.de>; Sun, 29 Oct 2006 20:10:26 +1300
Received: from taihua.otago.ac.nz ([139.80.35.27] helo=taihua)
  by galadriel.otago.ac.nz with smtp (Exim 4.50)
  id 1Ge4oH-0003m1-R6
  for grass-bugs@intevation.de; Sun, 29 Oct 2006 20:10:21 +1300
Date: Sun, 29 Oct 2006 20:10:26 +1300
From: Hamish <hamish_nospam@yahoo.com>
To: grass-bugs@intevation.de
Subject: d.vect: better random color generation
Message-Id: <20061029201026.72a37491.hamish_nospam@yahoo.com>
X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
X-Face: M<EoB)"*Z~u!,vFhXmw}R_KbdBta*P_=T|rbBL'e1/CQ9;/1g\BU3&!=y8ria$2Uk!HT&BB
8i?|X_+7~1jsy}F~g$2va%3fV`*=L(*cem[@3\yg,G,@rg6/QMJ
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd-new at intevation.de
X-Spam-Status: No, hits=1.7 tagged_above=-999 required=3 tests=[BAYES_20=-1,
FORGED_YAHOO_RCVD=2.7]
X-Spam-Level: *

-------------------------------------------- Managed by Request Tracker

Hi,

I have tried to implement random coloring using
G_make_random_colours(), see the attached patch for d.vect.

If there are no serious objections, I will committ the changes into
CVS. Then I will also try to implement random colors based on the
given attribute column.

Best regards, Martin

2006/10/29, Request Tracker <grass-bugs@intevation.de>:

this bug's URL: http://intevation.de/rt/webrt?serial_num=5243
-------------------------------------------------------------------------

[wish]

Hi,

currently "d.vect -c" random colors is limited to 16 colors, which do
not rotate between calls. (you get the same colors every time, d.redraw
doesn't help if you don't like the results)

see display/d.vect/plot.h for current candidates.

I suggest using random color code from lib/gis/color_rand.c to do a
better job. It seems to work pretty well.

or if that won't work (too many cats to store RGB values) start with
random seed and calculate R,G,B values by some mathematical function
which will give the same answers for those 3 variables within the module
run.

thanks,
Hamish

--- Headers Follow ---

>From hamish_nospam@yahoo.com Sun Oct 29 08:12:05 2006
Return-Path: <hamish_nospam@yahoo.com>
Delivered-To: grass-bugs@lists.intevation.de
Received: from kolab.intevation.de (aktaia [212.95.126.10])
        by lists.intevation.de (Postfix) with ESMTP id D9B871006AB
        for <grass-bugs@lists.intevation.de>; Sun, 29 Oct 2006 08:12:05 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
        by kolab.intevation.de (Postfix) with ESMTP id BFDC41B1A17
        for <grass-bugs@lists.intevation.de>; Sun, 29 Oct 2006 08:12:05 +0100 (CET)
Received: from localhost (localhost.localdomain [127.0.0.1])
        by kolab.intevation.de (Postfix) with ESMTP id A690B1AFCC3
        for <grass-bugs@lists.intevation.de>; Sun, 29 Oct 2006 08:12:05 +0100 (CET)
Received: from mailhub1.otago.ac.nz (mailhub1.otago.ac.nz [139.80.64.218])
        by kolab.intevation.de (Postfix) with ESMTP id B66381AD41A
        for <grass-bugs@intevation.de>; Sun, 29 Oct 2006 08:10:31 +0100 (CET)
Received: from galadriel.otago.ac.nz (galadriel.otago.ac.nz [139.80.64.213])
        by mailhub1.otago.ac.nz (8.13.6/8.13.6) with ESMTP id k9T7AQP8003694
        for <grass-bugs@intevation.de>; Sun, 29 Oct 2006 20:10:26 +1300
Received: from taihua.otago.ac.nz ([139.80.35.27] helo=taihua)
        by galadriel.otago.ac.nz with smtp (Exim 4.50)
        id 1Ge4oH-0003m1-R6
        for grass-bugs@intevation.de; Sun, 29 Oct 2006 20:10:21 +1300
Date: Sun, 29 Oct 2006 20:10:26 +1300
From: Hamish <hamish_nospam@yahoo.com>
To: grass-bugs@intevation.de
Subject: d.vect: better random color generation
Message-Id: <20061029201026.72a37491.hamish_nospam@yahoo.com>
X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
X-Face: M<EoB)"*Z~u!,vFhXmw}R_KbdBta*P_=T|rbBL'e1/CQ9;/1g\BU3&!=y8ria$2Uk!HT&BB
8i?|X_+7~1jsy}F~g$2va%3fV`*=L(*cem[@3\yg,G,@rg6/QMJ
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd-new at intevation.de
X-Spam-Status: No, hits=1.7 tagged_above=-999 required=3 tests=[BAYES_20=-1,
FORGED_YAHOO_RCVD=2.7]
X-Spam-Level: *

-------------------------------------------- Managed by Request Tracker

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

(attachments)

d_vect-rcols.diff.gz (5.99 KB)

Martin Landa wrote:

I have tried to implement random coloring using
G_make_random_colours(), see the attached patch for d.vect.

do multiple vector features with the same cat value have the same color?

general question: how to "lock-in" nice random colors once you find
them? e.g. populate GRASSRGB attribute column to survive d.redraw and
use with ps.map.

Then I will also try to implement random colors based on the given
attribute column.

how about "true" color scaling min->max like d.vect.thematic does with
value-bands?

cheers,
Hamish

Hi,

2006/11/18, Hamish <hamish_nospam@yahoo.com>:

Martin Landa wrote:
> I have tried to implement random coloring using
> G_make_random_colours(), see the attached patch for d.vect.

do multiple vector features with the same cat value have the same color?

yes, they should have the same color, e.g. (spearfish60)

d.erase;d.vect landuse dis=cat,shape -c

general question: how to "lock-in" nice random colors once you find
them? e.g. populate GRASSRGB attribute column to survive d.redraw and
use with ps.map.

One of the solutions: new flag -u to update color values to GRASSRGB
column in attribute table (like in d.vect.thematic). Do you have
better idea?

> Then I will also try to implement random colors based on the given
> attribute column.

how about "true" color scaling min->max like d.vect.thematic does with
value-bands?

cheers,
Hamish

Martin

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

Hi,

I am thinking about relationship between d.vect and d.vect.thematic.
BTW d.vect.themetic should be rewritten to C, is anybody working on
it? (sorry, I am trying to read every message in grass-dev, bad
memory;-). I am just wondering about d.vect X d.vect.thematic
modules...

Thanks for clarification.

Best regards, Martin

2006/11/18, Martin Landa <landa.martin@gmail.com>:

Hi,

2006/11/18, Hamish <hamish_nospam@yahoo.com>:
> Martin Landa wrote:
> > I have tried to implement random coloring using
> > G_make_random_colours(), see the attached patch for d.vect.
>
> do multiple vector features with the same cat value have the same color?

yes, they should have the same color, e.g. (spearfish60)

d.erase;d.vect landuse dis=cat,shape -c

> general question: how to "lock-in" nice random colors once you find
> them? e.g. populate GRASSRGB attribute column to survive d.redraw and
> use with ps.map.

One of the solutions: new flag -u to update color values to GRASSRGB
column in attribute table (like in d.vect.thematic). Do you have
better idea?

>
> > Then I will also try to implement random colors based on the given
> > attribute column.
>
> how about "true" color scaling min->max like d.vect.thematic does with
> value-bands?
>
> cheers,
> Hamish
>

Martin

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

Actually, random color generation and saving colors in the RGB column are a
kind of thematic mapping that should be integrated into a new and improved
d.vect.thematic. I think that Moritz Lennart's team is working on this.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Martin Landa <landa.martin@gmail.com>
Date: Sat, 18 Nov 2006 11:16:57 +0100
To: Hamish <hamish_nospam@yahoo.com>
Cc: <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] [bug #5243] (grass) d.vect: better random color
generation

Hi,

I am thinking about relationship between d.vect and d.vect.thematic.
BTW d.vect.themetic should be rewritten to C, is anybody working on
it? (sorry, I am trying to read every message in grass-dev, bad
memory;-). I am just wondering about d.vect X d.vect.thematic
modules...

Thanks for clarification.

Best regards, Martin

2006/11/18, Martin Landa <landa.martin@gmail.com>:

Hi,

2006/11/18, Hamish <hamish_nospam@yahoo.com>:

Martin Landa wrote:

I have tried to implement random coloring using
G_make_random_colours(), see the attached patch for d.vect.

do multiple vector features with the same cat value have the same color?

yes, they should have the same color, e.g. (spearfish60)

d.erase;d.vect landuse dis=cat,shape -c

general question: how to "lock-in" nice random colors once you find
them? e.g. populate GRASSRGB attribute column to survive d.redraw and
use with ps.map.

One of the solutions: new flag -u to update color values to GRASSRGB
column in attribute table (like in d.vect.thematic). Do you have
better idea?

Then I will also try to implement random colors based on the given
attribute column.

how about "true" color scaling min->max like d.vect.thematic does with
value-bands?

cheers,
Hamish

Martin

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

Michael Barton wrote:

Actually, random color generation and saving colors in the RGB column
are a kind of thematic mapping that should be integrated into a new
and improved d.vect.thematic. I think that Moritz Lennart's team is
working on this.

by the way, d.vect.thematic now stands out as the most complicated
module (with ~26 options) without any guisections tabs. Could someone
who both understands and uses this module split the options up into sub-
groups?

it is very simple, in the shell script just add (e.g.):
#% guisection: Colors
in the option definition.

see also:
http://wald.intevation.org/tracker/index.php?func=detail&aid=238&group_id=21&atid=182

thanks,
Hamish