If have a map with values from 0-255 I create a set of color rules such that
0% = green
100% = red
GRASS will create a color table that will assign a nice gradient of colors from 0:255:0 to 255:0:0 to the values from 0-255.
Is there any way when querying a single cell of that map to know what color has been assigned to it? Similarly, is there any way to know what color has been assigned to any value in the 0-255 range?
Michael
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
I was contemplating a wxPython histograming module, like the TclTk profiling
module, and liked the option in d.histogram of being able to use the color
table for the histogram colors. But this seems like a pretty intensive batch
of calculations to do it.
Michael
On 4/12/07 4:08 PM, "Glynn Clements" <glynn@gclements.plus.com> wrote:
Michael Barton wrote:
If have a map with values from 0-255 I create a set of color rules such that
0% = green
100% = red
GRASS will create a color table that will assign a nice gradient of colors
from 0:255:0 to 255:0:0 to the values from 0-255.
Is there any way when querying a single cell of that map to know what color
has been assigned to it?
Set a 1x1 region around the cell, then r.out.ppm | pnmnoraw | sed.
Or r.mapcalc 'out = (r#map * 256 + g#map) * 256 + b#map', query the
composite map and decode the category number.
Similarly, is there any way to know what color has
been assigned to any value in the 0-255 range?
Set a 1x1 region, r.mapcalc "tmp = $value", r.out.ppm ...
Seriously; this is how d.rast.edit.tcl does it.
Yeah; we could probably do with a "r.what.colors" module.
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
>> If have a map with values from 0-255 I create a set of color rules
>> such that
>> 0% = green
>> 100% = red
>>
>> GRASS will create a color table that will assign a nice gradient of
>> colors from 0:255:0 to 255:0:0 to the values from 0-255.
>>
>> Is there any way when querying a single cell of that map to know
>> what color has been assigned to it?
Glynn:
> Set a 1x1 region around the cell, then r.out.ppm | pnmnoraw | sed.
>
> Or r.mapcalc 'out = (r#map * 256 + g#map) * 256 + b#map', query the
> composite map and decode the category number.
>
>> Similarly, is there any way to know what color has
>> been assigned to any value in the 0-255 range?
>
> Set a 1x1 region, r.mapcalc "tmp = $value", r.out.ppm ...
>
> Seriously; this is how d.rast.edit.tcl does it.
>
> Yeah; we could probably do with a "r.what.colors" module.
Michael:
I was contemplating a wxPython histograming module, like the TclTk
profiling module, and liked the option in d.histogram of being able to
use the color table for the histogram colors. But this seems like a
pretty intensive batch of calculations to do it.
you could try "r.profile -c" with a profile which starts and stops at
the cell center (length=0). Also it should be very simple to add a flag
just like "r.profile -c" to r.what, if that helps.
But probably the most direct solution is a SWIG-Python interface to the
libgis color-lookup fns themselves.
Michael:
> >> If have a map with values from 0-255 I create a set of color rules
> >> such that
> >> 0% = green
> >> 100% = red
> >>
> >> GRASS will create a color table that will assign a nice gradient of
> >> colors from 0:255:0 to 255:0:0 to the values from 0-255.
> >>
> >> Is there any way when querying a single cell of that map to know
> >> what color has been assigned to it?
Glynn:
> > Set a 1x1 region around the cell, then r.out.ppm | pnmnoraw | sed.
> >
> > Or r.mapcalc 'out = (r#map * 256 + g#map) * 256 + b#map', query the
> > composite map and decode the category number.
> >
> >> Similarly, is there any way to know what color has
> >> been assigned to any value in the 0-255 range?
> >
> > Set a 1x1 region, r.mapcalc "tmp = $value", r.out.ppm ...
> >
> > Seriously; this is how d.rast.edit.tcl does it.
> >
> > Yeah; we could probably do with a "r.what.colors" module.
Michael:
> I was contemplating a wxPython histograming module, like the TclTk
> profiling module, and liked the option in d.histogram of being able to
> use the color table for the histogram colors. But this seems like a
> pretty intensive batch of calculations to do it.
you could try "r.profile -c" with a profile which starts and stops at
the cell center (length=0). Also it should be very simple to add a flag
just like "r.profile -c" to r.what, if that helps.
I have a version of r.what that I modified to optionally output RGB
color. If interested I could commit to CVS?
--
Bob
But probably the most direct solution is a SWIG-Python interface to the
libgis color-lookup fns themselves.
> > > Yeah; we could probably do with a "r.what.colors" module.
> Michael:
> > I was contemplating a wxPython histograming module, like the TclTk
> > profiling module, and liked the option in d.histogram of being able to
> > use the color table for the histogram colors. But this seems like a
> > pretty intensive batch of calculations to do it.
>
>
> you could try "r.profile -c" with a profile which starts and stops at
> the cell center (length=0). Also it should be very simple to add a flag
> just like "r.profile -c" to r.what, if that helps.
I have a version of r.what that I modified to optionally output RGB
color. If interested I could commit to CVS?
It may be useful to have that feature in r.what, although there would
still be some use for a module which looks up the colour for a
user-supplied value (e.g. d.rast.edit.tcl needs to be able to
determine the colour for new values which don't yet exist in the map).
This is fine, but I'm afraid that it won't help planned implementation. This
is partly because I didn't phrase my question correctly. What I really need
to know is what color is assigned to a cat value. The idea is to do
histogramming in wxPython. It might be nice to have the histogram show the
map colors like d.histogram can. To do that, I need to know the color
assigned to a cat. However, to get colors by querying every cell in a map
with r.what would take a very long time.
Michael
On 4/18/07 7:05 AM, "Bob Covill" <bcovill@tekmap.ns.ca> wrote:
On Thu, 2007-04-19 at 01:51 +1200, Hamish wrote:
Michael:
If have a map with values from 0-255 I create a set of color rules
such that
0% = green
100% = red
GRASS will create a color table that will assign a nice gradient of
colors from 0:255:0 to 255:0:0 to the values from 0-255.
Is there any way when querying a single cell of that map to know
what color has been assigned to it?
Glynn:
Set a 1x1 region around the cell, then r.out.ppm | pnmnoraw | sed.
Or r.mapcalc 'out = (r#map * 256 + g#map) * 256 + b#map', query the
composite map and decode the category number.
Similarly, is there any way to know what color has
been assigned to any value in the 0-255 range?
Set a 1x1 region, r.mapcalc "tmp = $value", r.out.ppm ...
Seriously; this is how d.rast.edit.tcl does it.
Yeah; we could probably do with a "r.what.colors" module.
Michael:
I was contemplating a wxPython histograming module, like the TclTk
profiling module, and liked the option in d.histogram of being able to
use the color table for the histogram colors. But this seems like a
pretty intensive batch of calculations to do it.
you could try "r.profile -c" with a profile which starts and stops at
the cell center (length=0). Also it should be very simple to add a flag
just like "r.profile -c" to r.what, if that helps.
I have a version of r.what that I modified to optionally output RGB
color. If interested I could commit to CVS?
--
Bob
But probably the most direct solution is a SWIG-Python interface to the
libgis color-lookup fns themselves.
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
On Wed, 2007-04-18 at 17:19 +0100, Glynn Clements wrote:
Bob Covill wrote:
> > > > Yeah; we could probably do with a "r.what.colors" module.
> > Michael:
> > > I was contemplating a wxPython histograming module, like the TclTk
> > > profiling module, and liked the option in d.histogram of being able to
> > > use the color table for the histogram colors. But this seems like a
> > > pretty intensive batch of calculations to do it.
> >
> >
> > you could try "r.profile -c" with a profile which starts and stops at
> > the cell center (length=0). Also it should be very simple to add a flag
> > just like "r.profile -c" to r.what, if that helps.
>
> I have a version of r.what that I modified to optionally output RGB
> color. If interested I could commit to CVS?
I have committed the change to r.what. It now has a "-r" flag (-c was
taken) that will output the RGB for the selected point.
Please test.
It may be useful to have that feature in r.what, although there would
still be some use for a module which looks up the colour for a
user-supplied value (e.g. d.rast.edit.tcl needs to be able to
determine the colour for new values which don't yet exist in the map).
If you are looking to duplicate d.histogram why not use r.stats? This
will output raster values with the percent or area which could be used
for plotting a histogram. If this did work it could be modified to
output the associated raster color along with the other values. Maybe I
am missing the point?
On a related issues I have used a modified version of r.stats for a
while now to create equalized color bars for raster maps. You simply
calculate the distribution over a set number of color breaks, drop a
custom colortable over the breaks and apply with r.colors rules=.
Hope this helps.
--
Bob
On Wed, 2007-04-18 at 09:30 -0700, Michael Barton wrote:
This is fine, but I'm afraid that it won't help planned implementation. This
is partly because I didn't phrase my question correctly. What I really need
to know is what color is assigned to a cat value. The idea is to do
histogramming in wxPython. It might be nice to have the histogram show the
map colors like d.histogram can. To do that, I need to know the color
assigned to a cat. However, to get colors by querying every cell in a map
with r.what would take a very long time.
Michael
On 4/18/07 7:05 AM, "Bob Covill" <bcovill@tekmap.ns.ca> wrote:
> On Thu, 2007-04-19 at 01:51 +1200, Hamish wrote:
>> Michael:
>>>>> If have a map with values from 0-255 I create a set of color rules
>>>>> such that
>>>>> 0% = green
>>>>> 100% = red
>>>>>
>>>>> GRASS will create a color table that will assign a nice gradient of
>>>>> colors from 0:255:0 to 255:0:0 to the values from 0-255.
>>>>>
>>>>> Is there any way when querying a single cell of that map to know
>>>>> what color has been assigned to it?
>> Glynn:
>>>> Set a 1x1 region around the cell, then r.out.ppm | pnmnoraw | sed.
>>>>
>>>> Or r.mapcalc 'out = (r#map * 256 + g#map) * 256 + b#map', query the
>>>> composite map and decode the category number.
>>>>
>>>>> Similarly, is there any way to know what color has
>>>>> been assigned to any value in the 0-255 range?
>>>>
>>>> Set a 1x1 region, r.mapcalc "tmp = $value", r.out.ppm ...
>>>>
>>>> Seriously; this is how d.rast.edit.tcl does it.
>>>>
>>>> Yeah; we could probably do with a "r.what.colors" module.
>> Michael:
>>> I was contemplating a wxPython histograming module, like the TclTk
>>> profiling module, and liked the option in d.histogram of being able to
>>> use the color table for the histogram colors. But this seems like a
>>> pretty intensive batch of calculations to do it.
>>
>>
>> you could try "r.profile -c" with a profile which starts and stops at
>> the cell center (length=0). Also it should be very simple to add a flag
>> just like "r.profile -c" to r.what, if that helps.
>
> I have a version of r.what that I modified to optionally output RGB
> color. If interested I could commit to CVS?
>
> --
> Bob
>
>
>>
>> But probably the most direct solution is a SWIG-Python interface to the
>> libgis color-lookup fns themselves.
>>
>>
>> Hamish
>>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev@grass.itc.it
>> http://grass.itc.it/mailman/listinfo/grass-dev
>
>
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
On 4/18/07 12:22 PM, "Bob Covill" <bcovill@tekmap.ns.ca> wrote:
Michael,
If you are looking to duplicate d.histogram why not use r.stats? This
will output raster values with the percent or area which could be used
for plotting a histogram. If this did work it could be modified to
output the associated raster color along with the other values. Maybe I
am missing the point?
On a related issues I have used a modified version of r.stats for a
while now to create equalized color bars for raster maps. You simply
calculate the distribution over a set number of color breaks, drop a
custom colortable over the breaks and apply with r.colors rules=.
Hope this helps.
--
Bob
On Wed, 2007-04-18 at 09:30 -0700, Michael Barton wrote:
This is fine, but I'm afraid that it won't help planned implementation. This
is partly because I didn't phrase my question correctly. What I really need
to know is what color is assigned to a cat value. The idea is to do
histogramming in wxPython. It might be nice to have the histogram show the
map colors like d.histogram can. To do that, I need to know the color
assigned to a cat. However, to get colors by querying every cell in a map
with r.what would take a very long time.
Michael
On 4/18/07 7:05 AM, "Bob Covill" <bcovill@tekmap.ns.ca> wrote:
On Thu, 2007-04-19 at 01:51 +1200, Hamish wrote:
Michael:
If have a map with values from 0-255 I create a set of color rules
such that
0% = green
100% = red
GRASS will create a color table that will assign a nice gradient of
colors from 0:255:0 to 255:0:0 to the values from 0-255.
Is there any way when querying a single cell of that map to know
what color has been assigned to it?
Glynn:
Set a 1x1 region around the cell, then r.out.ppm | pnmnoraw | sed.
Or r.mapcalc 'out = (r#map * 256 + g#map) * 256 + b#map', query the
composite map and decode the category number.
Similarly, is there any way to know what color has
been assigned to any value in the 0-255 range?
Set a 1x1 region, r.mapcalc "tmp = $value", r.out.ppm ...
Seriously; this is how d.rast.edit.tcl does it.
Yeah; we could probably do with a "r.what.colors" module.
Michael:
I was contemplating a wxPython histograming module, like the TclTk
profiling module, and liked the option in d.histogram of being able to
use the color table for the histogram colors. But this seems like a
pretty intensive batch of calculations to do it.
you could try "r.profile -c" with a profile which starts and stops at
the cell center (length=0). Also it should be very simple to add a flag
just like "r.profile -c" to r.what, if that helps.
I have a version of r.what that I modified to optionally output RGB
color. If interested I could commit to CVS?
--
Bob
But probably the most direct solution is a SWIG-Python interface to the
libgis color-lookup fns themselves.
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
> I have a version of r.what that I modified to optionally output RGB
> color. If interested I could commit to CVS?
It may be useful to have that feature in r.what, although there would
still be some use for a module which looks up the colour for a
user-supplied value (e.g. d.rast.edit.tcl needs to be able to
determine the colour for new values which don't yet exist in the map).
I have added such a module, name r.what.color.
Values can be passed either on the command line or on stdin, and the
corresponding colours are written on stdout.
If you are looking to duplicate d.histogram why not use r.stats? This
will output raster values with the percent or area which could be used
for plotting a histogram. If this did work it could be modified to
output the associated raster color along with the other values. Maybe
I am missing the point?
In fact d.histogram calls system("r.stats -Cr{c|a}...."); to get the
data it needs for its histogram.
On a related issues I have used a modified version of r.stats for a
while now to create equalized color bars for raster maps. You simply
calculate the distribution over a set number of color breaks, drop a
custom colortable over the breaks and apply with r.colors rules=.
On Wed, 2007-04-18 at 17:19 +0100, Glynn Clements wrote:
Bob Covill wrote:
Yeah; we could probably do with a "r.what.colors" module.
Michael:
I was contemplating a wxPython histograming module, like the TclTk
profiling module, and liked the option in d.histogram of being able to
use the color table for the histogram colors. But this seems like a
pretty intensive batch of calculations to do it.
you could try "r.profile -c" with a profile which starts and stops at
the cell center (length=0). Also it should be very simple to add a flag
just like "r.profile -c" to r.what, if that helps.
I have a version of r.what that I modified to optionally output RGB
color. If interested I could commit to CVS?
I have committed the change to r.what. It now has a "-r" flag (-c was
taken) that will output the RGB for the selected point.
I didn't follow this in detail, but with this new -r flag, what is
r.what.color providing?
Is there a need to keep it?
Markus (who always has an eye on too similar modules)
------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------
Including a "RGB"-flag into r.stats would still be a good thing.
Right now, creating a vector polygon layer with a GRASSRGB-column out of a raster map + colortable needs some manual input or custom shell scripting to set up tthe RGBCOLOR values.
Having a RGB-functionality in r.stats would make this (and other tasks) easier.
Peter
Bob Covill wrote on 04/18/2007 09:02 PM:
On Wed, 2007-04-18 at 17:19 +0100, Glynn Clements wrote:
Bob Covill wrote:
Yeah; we could probably do with a "r.what.colors" module.
Michael:
I was contemplating a wxPython histograming module, like the TclTk
profiling module, and liked the option in d.histogram of being able >to
use the color table for the histogram colors. But this seems like a
pretty intensive batch of calculations to do it.
you could try "r.profile -c" with a profile which starts and stops at
the cell center (length=0). Also it should be very simple to add a >flag
just like "r.profile -c" to r.what, if that helps.
I have a version of r.what that I modified to optionally output RGB
color. If interested I could commit to CVS?
I have committed the change to r.what. It now has a "-r" flag (-c was
taken) that will output the RGB for the selected point.
I didn't follow this in detail, but with this new -r flag, what is
r.what.color providing?
Is there a need to keep it?
Markus (who always has an eye on too similar modules)
>>> I have committed the change to r.what. It now has a "-r" flag (-c
>>> was taken) that will output the RGB for the selected point.
>>>
>> I didn't follow this in detail, but with this new -r flag, what is
>> r.what.color providing?
>>
>
> Arbitrary color lookup, not just the value at one specific x,y cell.
>
> I believe it is useful for Glynn's new d.rast.edit[.tcl] where the given
> cell isn't written for r.what to query.
>
Anyone willing to write description.html for r.what.color?
the rest of GRASS uniformly uses/expects %d:%d:%d (255:255:255) for that.
suggestion: either use 0x%02x%02x%02x (0xaabbcc) if output is primariliy
meant for sending to Tcl, or %d:%d:%d (255:255:255) if meant to be
useful to GRASS. "ff:ff:ff" seems to be a mix of methods and an anomaly.
or is there another reason?
what RGB triplet pattern does xwPython prefer?