[R-sig-Geo] Overlay bubble chart on map

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Aug 16 13:59:59 CEST 2009


On Sun, Aug 16, 2009 at 12:20 PM, Rebecca
Ross<rebecca.ross at plants.ox.ac.uk> wrote:
>
> Dear All,
>
> I am new to this list, so apologies if this question has been asked and
> answered many times before!
>
> I would like to overlay a bubble chart onto a map so that the bubbles
> correspond to particular points on the map. I have the shape file for the map
> and the lat long co-ordinates for the points. Could anyone tell me how to put
> the two together? The suggestions I found so far are plot.Map and plot.Spatial,
> neither of which work.
>
> I am working to a bit of a deadline, so a response today would be really
> helpful.

To read foo.shp:

install.packages("rgdal")

require(rgdal)
map = readOGR("/path/to/maps/","foo")
plot(map)

then you can do:

points(p$x,p$y)

 or whatever to overlay on it. If a 'bubble chart' is just points
scaled by some factor, you can either use the 'symbols' function in R
or use pch and cex options to plot - with something like:

p = data.frame(x=1:10,y=1:10,size=1:10)
plot(p$x,p$y,pch=19,cex=p$size)

 hope that helps!

Barry



More information about the R-sig-Geo mailing list