Opened 9 years ago

Closed 8 years ago

#2714 closed enhancement (fixed)

wish: logarithmic legend for raster maps

Reported by: veroandreo Owned by: grass-dev@…
Priority: normal Milestone: 7.2.0
Component: Display Version: svn-releasebranch72
Keywords: d.legend, gsoc2016, cartography Cc:
CPU: x86-64 Platform: All

Description

Hello

I have several raster maps of chlorophyll concentration (mg/m3) with mostly very small values (from 0.02 to 1.5) and few high values (between 20 and 100). When I use d.legend, as it linearly scales values from minimum to maximum, I cannot see variation in colors in those values I'm interested most, but the gradient almost only shows variation in higher values, which again, are the minority (see file attached).

Wish: A flag for logarithmic display of legend values or at least the possibility to set tick marks at desired values, i.e.: 0.01,0.1,1,10,100 (without loosing the continuos gradient, as in #1147) would be really appreciated in terms of visualization.

Hint: r.colors with logarithmic flag or transforming the raster to logarithm does not solve this issue, and one may not be interested in the logarithm of the variable, either, but just getting a good visualization of colors.

The problem is also seen in the manual of r.flow (http://grass.osgeo.org/grass71/manuals/r.flow.html#example). The third map is mostly "yellowish" but that color does not appear in the legend.

Thanks much in advance! Vero

Attachments (6)

example.png (162.5 KB ) - added by veroandreo 9 years ago.
example lacking logarithmic representation
log_leg.diff (26.2 KB ) - added by lazaa 8 years ago.
Added -l flag for logarithmic legend
logleg.png (17.3 KB ) - added by lazaa 8 years ago.
legend exa
chloro.png (121.2 KB ) - added by lazaa 8 years ago.
chloro2.png (18.1 KB ) - added by lazaa 8 years ago.
logarithmic.diff (25.5 KB ) - added by lazaa 8 years ago.
added option -digits

Download all attachments as: .zip

Change History (22)

by veroandreo, 9 years ago

Attachment: example.png added

example lacking logarithmic representation

comment:1 by neteler, 9 years ago

Milestone: 7.0.17.0.2

Ticket retargeted after 7.0.1 milestone closed

comment:2 by neteler, 9 years ago

Milestone: 7.0.27.0.3

Ticket retargeted after milestone closed

comment:3 by neteler, 9 years ago

Milestone: 7.0.3

Ticket retargeted after milestone closed

comment:4 by neteler, 9 years ago

Milestone: 7.0.4

Ticket retargeted after 7.0.3 milestone closed

comment:5 by veroandreo, 9 years ago

Keywords: gsoc2016 cartography added

comment:6 by martinl, 9 years ago

Milestone: 7.0.47.0.5

by lazaa, 8 years ago

Attachment: log_leg.diff added

Added -l flag for logarithmic legend

by lazaa, 8 years ago

Attachment: logleg.png added

legend exa

comment:7 by lazaa, 8 years ago

I added flag -l for logarithmic legend. I hadn't any good data so please feel free to test.

comment:8 by veroandreo, 8 years ago

I will test as soon as your diff is applied, but if you wanna test, here's a link to the data with which I created the first attachment:

https://dl.dropboxusercontent.com/u/59735456/chlorophyll_arg.tif

Note that the problem in this case is that most of the map has very low values, so it would be important that the legend had more "space" for those values rather than for the rest of them that are rather few.

I'm very happy that you are working on this :)

in reply to:  7 comment:9 by annakrat, 8 years ago

Replying to lazaa:

I added flag -l for logarithmic legend. I hadn't any good data so please feel free to test.

you can also just compute flow accumulation with

r.watershed -a elevation=elevation threshold=1000 accumulation=flowacc

I tested it by setting labels 1,10,100,1000 and there should be the same distance between them, but it's not, so there must some mistake. See an example of logarithmic legend here.

comment:10 by annakrat, 8 years ago

Also, please update your diff with changes I made to your previous diffs which are now committed. For example I changed the guisection of some new options and other things which I now see as removed in your diffs.

by lazaa, 8 years ago

Attachment: chloro.png added

comment:11 by lazaa, 8 years ago

Thanks for real data, it was much easier find the mistake. It gives better results now. At least on todo left. Digits after decimal point are displayed only when small value min-max range is used. I don't think that's disared option in case of logarithmic scale. I add a condition so now when logarithmic scale is used three digits after decimal point are displayed but maybe I should add new option so user can determine how many digits display?

in reply to:  10 comment:12 by lazaa, 8 years ago

Replying to annakrat:

Also, please update your diff with changes I made to your previous diffs which are now committed. For example I changed the guisection of some new options and other things which I now see as removed in your diffs.

I updated my diff, but I wasn't sure if there's any svn method I could use without losing my code for that so I did it manually.

in reply to:  11 ; comment:13 by veroandreo, 8 years ago

Replying to lazaa:

Thanks for real data, it was much easier find the mistake. It gives better results now.

Yes, it is better indeed. But check how the scale for chlorophyll proposed by NASA looks like (and how a logarithmic scale looks like in general): http://oceancolor.gsfc.nasa.gov/images/CHL_chlor_a_colorscale.png

Values should be equally spaced, "graphically" speaking (for example: 0.01, 0.03, 0.1, 0.3, 1.0, 3.0, 10.0) and therefore more space in the color palette is needed for lower values, i.e.: more space for "blues" "cyans" and "greens" in your example (there's still a lot of red).

...

but maybe I should add new option so user can determine how many digits display?

This could be useful in general :)

by lazaa, 8 years ago

Attachment: chloro2.png added

in reply to:  13 ; comment:14 by lazaa, 8 years ago

Replying to veroandreo:

Replying to lazaa:

Thanks for real data, it was much easier find the mistake. It gives better results now.

Yes, it is better indeed. But check how the scale for chlorophyll proposed by NASA looks like (and how a logarithmic scale looks like in general): http://oceancolor.gsfc.nasa.gov/images/CHL_chlor_a_colorscale.png

Values should be equally spaced, "graphically" speaking (for example: 0.01, 0.03, 0.1, 0.3, 1.0, 3.0, 10.0) and therefore more space in the color palette is needed for lower values, i.e.: more space for "blues" "cyans" and "greens" in your example (there's still a lot of red).

You're right, I used wrong formula to calculate the scale.

...

but maybe I should add new option so user can determine how many digits display?

This could be useful in general :)

by lazaa, 8 years ago

Attachment: logarithmic.diff added

added option -digits

in reply to:  14 comment:15 by veroandreo, 8 years ago

Replying to lazaa:

Replying to veroandreo:

Replying to lazaa:

Thanks for real data, it was much easier find the mistake. It gives better results now.

Yes, it is better indeed. But check how the scale for chlorophyll proposed by NASA looks like (and how a logarithmic scale looks like in general): http://oceancolor.gsfc.nasa.gov/images/CHL_chlor_a_colorscale.png

Values should be equally spaced, "graphically" speaking (for example: 0.01, 0.03, 0.1, 0.3, 1.0, 3.0, 10.0) and therefore more space in the color palette is needed for lower values, i.e.: more space for "blues" "cyans" and "greens" in your example (there's still a lot of red).

You're right, I used wrong formula to calculate the scale.

Looks much much better now! Thanks! :)

comment:16 by annakrat, 8 years ago

Milestone: 7.0.57.2.0
Resolution: fixed
Status: newclosed
Version: svn-releasebranch70svn-releasebranch72
Note: See TracTickets for help on using tickets.