[GRASSLIST:380] Legends

Hello,

I have several questions, all related to legends.

* What's the status of 'legend' in NVIZ ? Any implementation yet ?

* When displaying the legend of a CELL map, *all* the categories are
displayed, when in fact, one would be interested only in the categories
really displayed. Actually, it's worse: if your categories are not
continuous (eg 10,11,12,27), the legend reports *all* the categories from the
smallest to the largest, when one would expect only the categories defined
(in the previous example, I have 18 labels in my legend, when I only need 4).

Is there an easy work around ? I thought about reclassifying the map to get
successive categories, but of course, I lose my colors.
Do you think this could be implemented for a next version ? (Maybe by adding
another option to d.legend, like "display only the categories listed in the
first column of the 'colr/map file' )".

* Now, the opposite problem:
Is there a way to force GRASS to display a legend based on a given color
table, even if some categories are missing ?
For example, I have a FCELL map with values in the range 0-1000. The legend
starts at the lowest category (say, 127) and ends at the largest (say, 851),
when in fact, I expect a display from 0 to 1000.
Here again, any work around ? (apart forcing one of the cells to 0, and
another to 1000 ?) Could it be implemented for a next version ?

Thanks for any idea.

P.

--
------------------------------
Soil and Water Laboratory
Biological and Environmental Engineering Department
Cornell University
Riley-Robb Hall
ITHACA, NY 14853 - USA

Soil & Water Lab. wrote:

* When displaying the legend of a CELL map, *all* the categories are
displayed, when in fact, one would be interested only in the categories
really displayed. Actually, it's worse: if your categories are not
continuous (eg 10,11,12,27), the legend reports *all* the categories from the
smallest to the largest, when one would expect only the categories defined
(in the previous example, I have 18 labels in my legend, when I only need 4).

Is there an easy work around ? I thought about reclassifying the map to get
successive categories, but of course, I lose my colors.
Do you think this could be implemented for a next version ? (Maybe by adding
another option to d.legend, like "display only the categories listed in the
first column of the 'colr/map file' )".

"d.legend -n ..." will only display categories which have labels.

Also, r.resample will only include those categories which are used in
the result map. Combining the two may achieve the desired result (at
the cost of duplicating the map).

Both of your suggestions for extensions seem plausible; you might
consider adding them to the request tracker in the "wish" category:

  http://grass.itc.it/bugtracking/wish.html

--
Glynn Clements <glynn.clements@virgin.net>

* What's the status of 'legend' in NVIZ ? Any implementation yet ?

As I recall, it was being worked on in CVS:
grass/src.contrib/GMSL/NVIZ2.2/src/draw.c
  v1.6 7 weeks bob Added functions for N arrow, colorbar, and labels

Looks like it's there.

* When displaying the legend of a CELL map, *all* the categories are
displayed, when in fact, one would be interested only in the
categories really displayed. Actually, it's worse: if your categories
are not continuous (eg 10,11,12,27), the legend reports *all* the
categories from the smallest to the largest, when one would expect
only the categories defined (in the previous example, I have 18 labels
in my legend, when I only need 4).

Use d.legend's -n flag if you are using 5.0.1 or 5.0.2.

You could also try my new version with the use= option, which only
displays categories you select. e.g. use=10,11,12,27. I've been
meaning to put this in the 5.1 CVS, but haven't had the time lately to
put on the finishing touches.
http://bambi.otago.ac.nz/hamish/main.c.withUSE10

* Now, the opposite problem:
Is there a way to force GRASS to display a legend based on a given
color table, even if some categories are missing ?
For example, I have a FCELL map with values in the range 0-1000. The
legend starts at the lowest category (say, 127) and ends at the
largest (say, 851), when in fact, I expect a display from 0 to 1000.
Here again, any work around ? (apart forcing one of the cells to 0,
and another to 1000 ?) Could it be implemented for a next version ?

d.legend takes the color from the map. If the color doesn't exist in the
map, d.legend can't know what to use. I think it is a bad idea to have
d.legend try and extrapolate a color value or read directly from the
colr file and re-implement existing library functions. I suppose it
might be feasible to extend the default range with the range= option
with whatever library function the raster map uses to find its color
value if you wanted, but I have no plans to do so and don't think the
official version should do this either.

What you might do is create a second floating poing map with a range of
0.0-1000.0, then:
r.colors newmap rast=origmap
d.rast origmap
d.legend newmap -options...

Or use 'range=130,850 labelnum=5' (or labelnum=4) if you just want
prettier subdivision text.

hint: if you play with range and labelnum so (max-min)/(labelnum-1) is a
multiple of ten then the results will look ok... As this isn't exactly
user friendly I was playing with the idea of using ps.map's new f.p.
legend smarts. The results are quite nice, but it does remove some
control over what is drawn, so as of yet I am undecided.

Feedback is always welcomed.

Hamish

H Bowman wrote:

> * Now, the opposite problem:
> Is there a way to force GRASS to display a legend based on a given
> color table, even if some categories are missing ?
> For example, I have a FCELL map with values in the range 0-1000. The
> legend starts at the lowest category (say, 127) and ends at the
> largest (say, 851), when in fact, I expect a display from 0 to 1000.
> Here again, any work around ? (apart forcing one of the cells to 0,
> and another to 1000 ?) Could it be implemented for a next version ?

d.legend takes the color from the map. If the color doesn't exist in the
map, d.legend can't know what to use. I think it is a bad idea to have
d.legend try and extrapolate a color value or read directly from the
colr file and re-implement existing library functions. I suppose it
might be feasible to extend the default range with the range= option
with whatever library function the raster map uses to find its color
value if you wanted, but I have no plans to do so and don't think the
official version should do this either.

Note that there is a public mechanism for obtaining the extent of the
colour table, i.e. G_get_d_color_range().

However, I'm not sure whether that is actually the right approach.
It's arguable that there should be some notion of the "total" range,
distinct from the range of values which actually occur.

E.g. for intensity rasters (i.e. images), it would be useful to be
able to determine that e.g. 255 corresponds to "100%".

--
Glynn Clements <glynn.clements@virgin.net>

When doing a comparison between a series of maps (say temperature) it is important that the color for a given temperature remain the same throughout the whole series no matter what the range of individual maps might be. Is this possible?

David

Glynn Clements wrote:

H Bowman wrote:

* Now, the opposite problem:
Is there a way to force GRASS to display a legend based on a given
color table, even if some categories are missing ?
For example, I have a FCELL map with values in the range 0-1000. The
legend starts at the lowest category (say, 127) and ends at the
largest (say, 851), when in fact, I expect a display from 0 to 1000.
Here again, any work around ? (apart forcing one of the cells to 0,
and another to 1000 ?) Could it be implemented for a next version ?

d.legend takes the color from the map. If the color doesn't exist in the
map, d.legend can't know what to use. I think it is a bad idea to have
d.legend try and extrapolate a color value or read directly from the
colr file and re-implement existing library functions. I suppose it
might be feasible to extend the default range with the range= option
with whatever library function the raster map uses to find its color
value if you wanted, but I have no plans to do so and don't think the
official version should do this either.

Note that there is a public mechanism for obtaining the extent of the
colour table, i.e. G_get_d_color_range().

However, I'm not sure whether that is actually the right approach. It's arguable that there should be some notion of the "total" range,
distinct from the range of values which actually occur.

E.g. for intensity rasters (i.e. images), it would be useful to be
able to determine that e.g. 255 corresponds to "100%".

--
David Finlayson
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

Hamish

> d.legend takes the color from the map. If the color doesn't exist in the
> map, d.legend can't know what to use. I think it is a bad idea to have
> d.legend try and extrapolate a color value or read directly from the
> colr file and re-implement existing library functions.

Glynn

However, I'm not sure whether that is actually the right approach.
It's arguable that there should be some notion of the "total" range,
distinct from the range of values which actually occur.

David

When doing a comparison between a series of maps (say temperature) it is
important that the color for a given temperature remain the same
throughout the whole series no matter what the range of individual maps
might be. Is this possible?

Seems that Glynn , David and I are thinking about the same thing: there should
be the possibility to display a smooth legend from a given minimum to a given
maximum, provided that the min and max values of the current map fall in the
legend range, that a color table has been defined, and the user-defined
extrema are covered by the colortable. That's just a matter of taking the
extrema from the colortable, not from the map. Anyway, if there are some
cells falling outside the colortable range, they are not displayed, and the
legend is not affected.

Right now, the trick seems to define a temporary map (TMP), with some cells
set to the "absolute" minimum, some others to the "absolute" maximum, with
the same colortable as wanted for the other maps. Instead of displaying the
current map legend, one displays the TMP legend instead...

P.

--
------------------------------
Soil and Water Laboratory
Biological and Environmental Engineering Department
Cornell University
Riley-Robb Hall
ITHACA, NY 14853 - USA

David Finlayson wrote:

When doing a comparison between a series of maps (say temperature) it is
important that the color for a given temperature remain the same
throughout the whole series no matter what the range of individual maps
might be. Is this possible?

Yes. Either:

a) specify the colour table explicitly, with
"r.colors ... color=rules", or

b) find (or create) a map whose value range covers the entire range,
create any colour table for that, then copy it to the other maps with
"r.colors ... rast=...".

--
Glynn Clements <glynn.clements@virgin.net>