Skip to content

maps and lattice

3 messages · Jon Loehrke, Sundar Dorai-Raj, Paul Hiemstra

#
Jon Loehrke said the following on 2/5/2008 2:29 PM:
Try this:

library(lattice)
library(maps)
long <- c(-69.2, -69.5, -70.1, -70.3)
lat <- c(41, 41.5, 43.2, 42.8)
fact <- c(1, 1, 2, 2)
xyplot(lat ~ long | fact,
        panel = function(...) {
          panel.xyplot(...)
          mp <- map("state", "massachusetts", plot = FALSE)
          lpolygon(mp$x, mp$y)
        })

HTH,

--sundar
#
Hi,

I use the spplot function from the sp package, it uses lattice to make 
spatial plots. The sp-package provides spatial classes for R. See 
http://r-spatial.sourceforge.net/ for more information on the use of 
spatial data in R, http://r-spatial.sourceforge.net/gallery/ gives a 
gallery of spatial plots with the R code it was created by. For 
questions on spatial data in R the r-sig-geo mailing list is also a good 
option (https://stat.ethz.ch/mailman/listinfo/r-sig-geo).

hope this helps!

Paul
Jon Loehrke wrote: