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

AdamWilson adammichaelwilson2 at gmail.com
Wed Jun 11 15:56:55 CEST 2014


It's possible to use the colortable metadata in levelplot like this:

library(rasterVis)
f <- system.file("external/test.grd", package="raster")
r <- round(raster(f))

## assign a color table
## if the original raster (on disk) had a color table it should already be
in this slot
r at legend@colortable=rainbow(cellStats(r,max))
str(r)

## 'normal' levelplot
levelplot(r)

## use the color table instead. Could write a simple wrapper function for
this...
## this might not work for all color tables....
cols=r at legend@colortable
levelplot(r,col.regions=cols,at=0:length(cols))




--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/rasterVis-levelplot-Use-colortable-in-raster-with-attribute-table-tp7585716p7586573.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list