[R-sig-Geo] rasterVis levelplot: Use colortable in raster with attribute table

Oscar Perpiñan oscar.perpinan at upm.es
Fri Feb 7 19:40:39 CET 2014


Hello,

> I am trying to plot a raster which comes with an attribute table and a colortable using the rasterVis levelplot function.
>
> Here is my first question: is it possible to address the colortable slot directly in the levelplot function (as is possible for the plot3D through the useLegend argument)?

Not yet. It is still in my To-do list.

> Since I did not find a way to do it, I tried the below. Note that the original attribute table is not arranged as is neccessary for levelplot to read it so I first create a new raster and assign to it the attributes which are needed:
> I know the procedure is improvable but for now I think it should do. The problem: Everything is plotted fine as expected, except that the last two classes of the raster are assigned the same color. Since there are the same number of classes as number of colors I do not really understand why this happens and, strange enough, in the color key all colors are plotted fine with the correct labels....additionally, when i do it using the plot() function it is working fine. When I used a different color ramp for levelplot it worked out for all classes and everything was well differentiated... Is there maybe some hex color code which levelplot can't read? Please appologize if I didn't express clearly what I want but I am still at the beginning of using R.

I don't understand what you are trying to do with your code. Could you
provide a reproducible example? Try the examples of the ratify help
page.

Best,

Oscar.



More information about the R-sig-Geo mailing list