[R-sig-Geo] Map2points() substitute for class "map"

Roger Bivand Roger.Bivand at nhh.no
Mon Feb 12 16:30:17 CET 2007


On Mon, 12 Feb 2007, Edzer J. Pebesma wrote:

> 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.

Very nice, and respecting the polygon bounding box too!

Roger

> --
> Edzer
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list