[R-sig-Geo] image background for spplot of gridded data
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Fri Nov 15 22:55:19 CET 2013
On 11/15/2013 08:13 PM, Waichler, Scott R wrote:
> 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?
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.
>
> Thanks,
> Scott Waichler
> Pacific Northwest National Laboratory
> Richland, WA, USA
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20131115/44f62b72/attachment.bin>
More information about the R-sig-Geo
mailing list