Skip to content

image background for spplot of gridded data

2 messages · Waichler, Scott R, Edzer Pebesma

#
Hi,

I have a map tile from RgoogleMaps that I want to use as a background image for an spplot of gridded data, where the data will be plotted with an alpha value < 1.  I am unable to plot them together. 

I was going to set up an example with meuse.grid, but I couldn't get CRS() to work with the meuse spec provided in the rgdal documentation.  So allow me to show as simply as I can with my code:

# background image
backgr <- list('grid.raster', myGoogleMapTile, x=x.ftCenter, y=y.ftCenter,
               width=backgr.width.ft, height=backgr.height.ft, default.units='native')
my.layout <- list(backgr)  

# data frame df has x, y, and z columns
coordinates(df) <- c("x", "y")
spdf <- as(df, "SpatialPixelsDataFrame")

spplot(spdf)  # plots df only, as expected
spplot(spdf, sp.layout=my.layout)  # only the background image and colorkey show

Thinking that the second call of spplot() is plotting the background image over the gridded data, I tried using first=T as shown below, but both ways generated an error message.  

backgr <- list('grid.raster', myGoogleMapTile, x=x.ftCenter, y=y.ftCenter,
               width=backgr.width.ft, height=backgr.height.ft, default.units='native', first=T)
my.layout <- list(backgr, first=T)

What am I missing here?

Thanks,
Scott Waichler
Pacific Northwest National Laboratory
Richland, WA, USA
#
On 11/15/2013 08:13 PM, Waichler, Scott R wrote:
1. an example that we can reproduce
2. after loading sp, demo(meuse, ask=FALSE) sets the CRS for meuse
3. understanding that spplot uses lattice, and hence does not let you
plot incrementally
4. prior emails from Oscar on this list that explain how to do what you want

Having some of these things made easy and documented somewhere, e.g. in
a vignette, is high on my wish list.