In accordance with this discussion , here is one way to do this: it consists in splitting the SpatialPolygonsDataFrame into a single coordinate matrix of polygons separated by NS. Then build it at level using panel.polygon .
library(maptools) a <- matrix(rnorm(360*180),nrow=360,ncol=180)
And this is where the fun begins:
lb <- as(b, "SpatialPolygons") llb <- slot(lb, "polygons") B <- lapply(llb, slot, "Polygons")
And then there is a conspiracy:
levelplot(a, panel=function(...){ panel.levelplot(...) panel.polygon(coords)})
The idea in the grid is to define the build functions in the panel argument (see ?xyplot for a full explanation on this). The function of the level itself is the levelplot .

Of course, in your case, it seems easier to do this using base graphics:
image(seq(-180,180,by=1),seq(-90,90,by=1),a) plot(b, add=TRUE)

source share