I have a bunch of data that I built at the county level without borders . I would like to add to state borders. I have a shapefile status file (polygons), but spplot does not seem to be able to add on top of the previous map. Is there a way to do this without rewriting the panel function to take two SPDFs (which seems pretty specialized for what is probably other people's problem)?
Here's a reproducible example:
library(sp) Srs1 = Polygons(list(Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))), "s1") Srs2 = Polygons(list(Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))), "s2") county <- SpatialPolygonsDataFrame( SpatialPolygons(list(Srs1,Srs2)), data.frame( z=1:2, row.names=c("s1","s2") ) ) SrsA <- Polygons(list(Polygon(cbind(c(3,5,5,1,3),c(3,4,6,5,3)))),"sA") state <- SpatialPolygonsDataFrame( SpatialPolygons(list(SrsA)), data.frame( z=1,row.names="sA" )) spplot( county, zcol="z",col=NA ) spplot( state, add=TRUE )
Ari B. Friedman
source share