[R-sig-Geo] Use a PNG image as background for lattice plotting with rasterVis

Waichler, Scott R Scott.Waichler at pnnl.gov
Mon Oct 21 20:15:52 CEST 2013


Thank you, Oscar.  The use of sp.layout in your web example was the key for me.  I hadn't worked with ggmap until now, but the added features it has over RgoogleMaps are quite helpful, and unlike RgoogleMaps, all of the arguments for ggmap functions are explained in the help.  

Regards,
Scott Waichler


> -----Original Message-----
> From: Oscar Perpiñan [mailto:oscar.perpinan at gmail.com]
> Sent: Saturday, October 19, 2013 1:06 AM
> To: Waichler, Scott R
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Use a PNG image as background for lattice
> plotting with rasterVis
> 
> Hello,
> Let's suppose that 'gmap' is the image resulting from a GetMap.bbox() call
> and 'r' is your Raster*.  A suitable solution is:
> library(rasterVis)
> levelplot(r) + layer_(grid.raster(gmap,
>                                                              x=lonCenter,
> y=latCenter,
>                                                              width=width,
> height=height,
> 
> default.units='native'))
> The 'lonCenter', 'latCenter', 'width' and 'height' parameters have to be
> extracted from the image attributes. In the next links you will find an
> example using ggmap (which is built upon RgoogleMaps). Between lines 17
> and 25 you will find details to extract them:
> https://gist.github.com/oscarperpinan/5451682
> http://procomun.wordpress.com/2013/04/24/stamen-maps-with-spplot/
> 
> Perhaps you will have to play with the 'alpha' values to mix the result of
> levelplot and grid.raster.
> Best,
> Oscar Perpiñán Lamigueiro
> Grupo de Sistemas Fotovoltaicos (IES-UPM)
> Dpto. Ingeniería Eléctrica (EUITI-UPM)
> URL: http://oscarperpinan.github.io
> Twitter: @oscarperpinan
> LinkedIn: http://es.linkedin.com/in/oscarperpinan
> El 18/10/2013 23:56, "Waichler, Scott R" <Scott.Waichler at pnnl.gov>
> escribió:
> Hi,
> 
> I've learned the basics of using RgoogleMaps and rasterVis, and now I want
> to combine their capabilities to use levelplot() with a georeferenced PNG
> image as a background in the lattice panel.  And, I want to plot to the
> normal R graphics devices, not the web as package plotGoogleMaps does.
>  Can anyone provide an example of how to use the result of RgoogleMaps'
> GetMap.bbox() as a background image in a plot produced with the rasterVis
> version of lattice graphics?
> 
> Thanks,
> Scott Waichler
> Pacific Northwest National Laboratory
> Richland, WA USA
> scott.waichler at pnnl.gov
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list