title: legend of spatial objects on top raster background
body: <p>There are good examples how to overlay vector/raster maps on raster layers like <a href="https://rpubs.com/alobo/vectorOnraster" rel="nofollow noreferrer">Plotting vector maps overlaid on top of a raster background in R</a> or <a href="http://rstudio-pubs-static.s3.amazonaws.com/16948_38af70d4c22e45df84a2fd69d8698d93.html" rel="nofollow noreferrer">Overlay your raster layer on a background GM layer in R</a>. But the legends are missing in the merged graphic. In the example <code>rproblv</code> has a legend but <code>migmaplv + rproblv</code> not.  </p>
  
  <p>Is there a easy way to combine two <code>levelplot</code> or <code>spplot</code> objects and preserve one or both legends in the result?</p>
  
  <p>From <a href="http://rstudio-pubs-static.s3.amazonaws.com/16948_38af70d4c22e45df84a2fd69d8698d93.html" rel="nofollow noreferrer">Overlay your raster layer on a background GM layer in R</a></p>
  
  <pre><code>library(utils); library(colorRamps); library(rgdal);
  library(raster); library(dismo); library(rasterVis)
  
  download.file(
    "https://dl.dropboxusercontent.com/u/3180464/rprob520.tif", 
    "rprob520.tif", method = "curl")
  
  rprob &lt;- raster("rprob520.tif")
  rprobGM &lt;- projectRaster(from = rprob, crs = CRS("+init=epsg:3857"))
  
  migmap &lt;- gmap(x = rprob, type = "hybrid", zoom = 5)
  
  migmaplv &lt;- levelplot(
    migmap, maxpixels = ncell(migmap), 
    col.regions = migmap@legend@colortable, 
    at = 0:255, panel = panel.levelplot.raster, interpolate = TRUE, 
    colorkey = FALSE, margin = FALSE)
  
  rproblv &lt;- levelplot(
    rprobGM, margin = FALSE, contour = TRUE, 
    par.settings = rasterTheme(region = matlab.like(n = 10)), 
    alpha.regions = 0.35, at = (0:10)/10, 
    main = "p(dep &gt; 1kg/m2 per eruption event)")
  
  print(migmaplv + rproblv)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/oBAai.png" alt="enter image description here"></p>