[R-sig-Geo] image background for spplot of gridded data

Waichler, Scott R Scott.Waichler at pnnl.gov
Fri Nov 15 20:13:28 CET 2013


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



More information about the R-sig-Geo mailing list