[R-sig-Geo] colortables in raster
Robert J. Hijmans
r.hijmans at gmail.com
Tue May 14 07:36:35 CEST 2013
Mike, The legend slot exist for that kind of applications but the code
to use it has not yet been written (at least not by me); In the raster
package it is currently only used for color tables. Robert
On Mon, May 6, 2013 at 10:52 PM, Michael Sumner <mdsumner at gmail.com> wrote:
> Hello, I would like to use the @legend feature of raster to somehow
> provide an absolute pallete across different objects. I thought
> originally that I could just set the @legend at values and
> @legend at colortable:
>
>
> r <- raster(volcano)
> r at legend@values <- seq(min(volcano), max(volcano), length = 125)
> r at legend@colortable <- heat.colors(124)
>
> ## but, this doesn't work right since the getValues(r) should be
> indices into r at legend@colortable
> plot(r)
>
> ## we can recompute the values as indices, so it works
> vs <- getValues(r)
>
> r <- setValues(r, 1 + (124 * (vs - min(vs))/diff(range(vs))))
> plot(r)
>
> But, I would like to use the embedded legend like this in order to
> keep the original range of getValues(r), but have the plotting build
> the appropriate (absolute) colour map
> from the @legend object. I'd also like it show the drawn legend when
> the plot is done (like in .plotraster), rather than it being dropped
> (as in .plotCT).
>
> Is there any way to do this currently, other than to explicitly
> provide the "col" and "breaks" arguments for plotting? I appreciate
> that I'm probably missing something obvious hacking around here.
>
> Cheers, Mike.
>
>
>
>
> --
> Michael Sumner
> Hobart, Australia
> e-mail: mdsumner at gmail.com
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list