[R-sig-Geo] Trellis with spplot

N St tuthalija at gmail.com
Wed Sep 3 16:41:24 CEST 2014


Hello

I would like to facet a spplot with the factors of one variable (like
a xyplot(y~x|A)). I want to use spplot because I have to add others
polygons layers. In my reproducible example below I would like to end
up with three plots, one for each categorie (1,2,3) in a trellis

--------------------------

library(sp); library(lattice) ; library(RColorBrewer) ; library(latticeExtra)
data(meuse)
coordinates(meuse) <- c("x", "y")
cc <- coordinates(meuse)
m.sl <- SpatialLines(list(Lines(list(Line(cc)), "line1")))
data(meuse.riv)
meuse.lst <- list(Polygons(list(Polygon(meuse.riv)), "meuse.riv"))
meuse.pol <- SpatialPolygonsDataFrame(SpatialPolygons(meuse.lst),
data.frame(1), match.ID=FALSE)

colfactor = RColorBrewer:::brewer.pal(3,"Accent")
pts <- list("sp.points", meuse, pch = 16, col = colfactor, cex=2,  )
meuse.layout <- list(pts)

l <- spplot(meuse, c("soil"), scales=list(draw=T), asp="iso",
col.regions=colfactor, cex=2)
p <- spplot(meuse.pol, fill="blue")
l+p


-----------------------------
It sounds really easy but I couldn't find an answer.

Best Regards
Nebi



More information about the R-sig-Geo mailing list