Skip to content
Prev 21532 / 29559 Next

Question with spplot for publication

Hi Ma,

You should be able to plot the polygon on top of your raster with a 
panel function. Here is an example with the meuse data:

r <- raster(system.file("external/test.grd", package="raster"))
s <- stack(r, r*2)
names(s) <- c('meuse', 'meuse x 2')
spplot(s)
data(meuse.riv)

meuse.sr = 
SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv")))

spplot(s,
   panel = function(x, y, ...) {
     panel.gridplot(x, y, ...)
     sp.polygons(meuse.sr)
   }
)

Is this more or less how you want it?

Cheers,
Jon
On 8/22/2014 9:15 AM, Ziyu Ma wrote: