[R-sig-Geo] Map2points() substitute for class "map"
Edzer J. Pebesma
e.pebesma at geo.uu.nl
Mon Feb 12 16:13:18 CET 2007
Roger Bivand wrote:
> Would it be sensible to include ProportionalSymbolMap() in maptools? In
> fact, it is the legend that is the tough problem, so in fact using the
> bubble-plot method in sp may be an easier way forward:
>
> SPDF <- SpatialPointsDataFrame(coordinates(ill), data=data.frame(x=x),
> proj4string=CRS("+proj=longlat"))
> bubble(SPDF, "x", axes=TRUE)
>
> There does not seem to be an easy way to plot the polygon borders as a
> background in the bubble method, which uses lattice graphics.
>
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
More information about the R-sig-Geo
mailing list