Opened 4 years ago

Closed 3 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 4 years ago.
example lacking logarithmic representation
log_leg.diff (26.2 KB) - added by lazaa 3 years ago.
Added -l flag for logarithmic legend
logleg.png (17.3 KB) - added by lazaa 3 years ago.
legend exa
chloro.png (121.2 KB) - added by lazaa 3 years ago.
chloro2.png (18.1 KB) - added by lazaa 3 years ago.
logarithmic.diff (25.5 KB) - added by lazaa 3 years ago.
added option -digits

Download all attachments as: .zip

Change History (22)

Changed 4 years ago by veroandreo

Attachment: example.png added

example lacking logarithmic representation

comment:1 Changed 4 years ago by neteler

Milestone: 7.0.17.0.2

Ticket retargeted after 7.0.1 milestone closed

comment:2 Changed 4 years ago by neteler

Milestone: 7.0.27.0.3

Ticket retargeted after milestone closed

comment:3 Changed 4 years ago by neteler

Milestone: 7.0.3

Ticket retargeted after milestone closed

comment:4 Changed 4 years ago by neteler

Milestone: 7.0.4

Ticket retargeted after 7.0.3 milestone closed

comment:5 Changed 3 years ago by veroandreo

Keywords: gsoc2016 cartography added

comment:6 Changed 3 years ago by martinl

Milestone: 7.0.47.0.5

Changed 3 years ago by lazaa

Attachment: log_leg.diff added

Added -l flag for logarithmic legend

Changed 3 years ago by lazaa

Attachment: logleg.png added

legend exa

comment:7 Changed 3 years ago by lazaa

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

comment:8 Changed 3 years ago by veroandreo

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 :)

comment:9 in reply to:  7 Changed 3 years ago by annakrat

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 Changed 3 years ago by 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.

Changed 3 years ago by lazaa

Attachment: chloro.png added

comment:11 Changed 3 years ago by lazaa

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?

comment:12 in reply to:  10 Changed 3 years ago by lazaa

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.

comment:13 in reply to:  11 ; Changed 3 years ago by 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).

...

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

This could be useful in general :)

Changed 3 years ago by lazaa

Attachment: chloro2.png added

comment:14 in reply to:  13 ; Changed 3 years ago by 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.

...

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

This could be useful in general :)

Changed 3 years ago by lazaa

Attachment: logarithmic.diff added

added option -digits

comment:15 in reply to:  14 Changed 3 years ago by veroandreo

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 Changed 3 years ago by annakrat

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