Skip to content
Prev 1736 / 29559 Next

Map2points() substitute for class "map"

Roger Bivand wrote:
Perhaps something along the lines of:

library(maps)
map <- map("county", "illinois", fill=TRUE, col="transparent", plot=FALSE)
library(maptools)
str(map)
ID <- substring(map$names, 10)
ill <- map2SpatialPolygons(map, ID, proj4string=CRS("+proj=longlat"))
plot(ill, axes=TRUE)
x <- runif(102)
SPDF <- SpatialPointsDataFrame(coordinates(ill), data=data.frame(x=x),
  proj4string=CRS("+proj=longlat"))

mypanel = function(x,y, subscripts, sp.layout, ...) {
    sp:::sp.panel.layout(sp.layout, panel.number())
    lattice:::panel.xyplot(x, y, ...)
}

sp.layout = list("sp.polygons", ill)
bubble(SPDF, "x", scales=list(draw=TRUE), panel = mypanel, sp.layout = 
sp.layout)


I agree this is rather ugly with all the ::: ; will see that bubble gets 
a sp.layout argument.
--
Edzer