[R-sig-Geo] Trellis with spplot

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


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)
coordinates(meuse) <- c("x", "y")
cc <- coordinates(meuse)
m.sl <- SpatialLines(list(Lines(list(Line(cc)), "line1")))
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")

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

Best Regards

More information about the R-sig-Geo mailing list