[GRASS-dev] [GRASS GIS] #3043: Change default color table
GRASS GIS
trac at osgeo.org
Wed Jun 22 08:03:41 PDT 2016
#3043: Change default color table
--------------------------+---------------------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: blocker | Milestone: 7.2.0
Component: Raster | Version: svn-trunk
Resolution: | Keywords: r.colors, d.rast, rainbow
CPU: Unspecified | Platform: Unspecified
--------------------------+---------------------------------------
Comment (by wenzeslaus):
Replying to [comment:20 vincent]:
> Replying to [comment:19 wenzeslaus]:
> > I would definitively include it (not necessarily as new `greens`
(#3055) but perhaps as `grass`)
>
> The point is : to preserve constant deltas in the ramp we need to keep
the right progress of colors
Yes.
> i.e. the rule file cannot be of proportional type as understood by
GRASS.
Can you please provide an example to help me understand? Ideally using
`r.colors.matplotlib` input and output.
Anyway, what we would need is a color table which is constructed using the
model in viscm, but that's just too complicated (I guess) and I don't
think [http://matplotlib.org//api/colors_api.html Matplotlib] is doing
anything like this, although I'm not sure what is the difference between
`ListedColormap` and `LinearSegmentedColormap.from_list`. It seems that
[https://github.com/BIDS/colormap BIDS/colormap] is using them in a same
way ([https://github.com/BIDS/colormap/blob/master/colormaps.py
ListedColormap], [https://github.com/BIDS/colormap/blob/master/option_a.py
LinearSegmentedColormap.from_list]).
In `r.colors.matplotlib` I try to do the conversion from the Matploitlib
objects to GRASS color rules. The GRASS rules are linearly interpolated in
between (when used) which is what happens in the Matplotlib objects I
think. This is not ideal but with enough steps, it is a smaller problem. I
struggle with what is enough and how to implement it. It seems that six
colors give visually the same color tables as originals (so default is
`ncolors=6`), however for reading the viscm generated files, I'm using
whatever number is in the file (this way is also easier to implement).
> The output from viscm has 256 steps,
That's right. It's 256 steps, not values from 1 to 256. In
`r.colors.matplotlib` (in case of viscm output) I convert `ListedColormap`
which is created from the following list:
{{{
[[ 0.02099905, 0.14497527, 0.14510218],
[ 0.02128463, 0.14850087, 0.147124 ],
[ 0.02135256, 0.15204182, 0.14916189],
...
[ 0.9776095 , 0.92497705, 0.69352479],
[ 0.9815921 , 0.92876498, 0.70167807],
[ 0.98557933, 0.93256261, 0.70987881]]
}}}
to GRASS color rules:
{{{
0.000% 5:37:37
0.392% 5:38:37
0.784% 5:38:38
...
99.216% 250:236:177
99.608% 251:237:179
100.000% 252:238:181
}}}
> one just needs to turn RGB percents into 0-255 values.
As far as I understand, that's unrelated to the above. This is RGB triplet
format issue (`0-1 -> 0-255`). I hope I'm doing it right in
`r.colors.matplotlib`:
{{{
# taken from color_rules.c
r1 = int(r1 * 255.999)
g1 = int(g1 * 255.999)
b1 = int(b1 * 255.999)
}}}
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3043#comment:21>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list