[R-sig-Geo] how to use levelplot() with a geographic projection

Waichler, Scott R Scott.Waichler at pnnl.gov
Mon Aug 26 19:50:17 CEST 2013


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.waichler at pnnl.gov
509-996-8260, 509-341-4051 (cell)



More information about the R-sig-Geo mailing list