Scott--
Instead of using lattice::levelplot directly, you can use the raster
package for your regular grid data + projection information, and the
rasterVis package rasterVis::levelplot.   You can then either use
panel.spplot to overlay your state outline polygons, or use
latticeExtra:layer and spplot() to add the state outlines.
You may need to use spTransform() on your state outline polygons or
projectRaster on the grid to get them both in the same desired projection.

Tom



On Mon, Aug 26, 2013 at 10:50 AM, Waichler, Scott R <scott.waich...@pnnl.gov
> wrote:

> Hi, I am making lattice plots with levelplot(), where my data are on a
> regular grid in longitude and latitude, and I want to plot state boundaries
> as an overlay for reference.  How can I do this so that the plot looks more
> geographically true, with states having the appearance we are used to?  The
> extent of my plot regions is on the order of state of Texas or the Pacific
> Northwest.
>
> library(lattice)
> library(maps)
> data(stateMapEnv)
> state.map <- map("state", plot=F)
>
> MAPPLOT1 <- function() {
>   print(
>   levelplot(zvec ~ xvec + yvec | pvec, asp="iso",
>             panel = function(...) {
>               panel.levelplot(...)
>               llines(state.map$x, state.map$y, col="black")
>             },
>             xlab="Longitude", ylab="Latitude"
>   ))
>   dev.off() # close the graphics file for this date
> }  # end MAPPLOT1()
>
> Thanks,
> Scott
>
> Scott Waichler, PhD
> Senior Research Scientist
> Hydrology Group, Energy & Environment Directorate
> Pacific Northwest National Laboratory
> P.O. Box 999, Richland, WA  99352
> scott.waich...@pnnl.gov
> 509-996-8260, 509-341-4051 (cell)
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to