[R-sig-Geo] Spatial network plots?

Ben Madin lists at remoteinformation.com.au
Wed Dec 15 23:57:12 CET 2010


I would suggest that you are on the right track - I am using network / sna / igraph packages for this and I am quite happy with the results. The 'geography' trick is realising that the various layout functions return a set of points - normally in a matrix. You can alternatively look these points up from a data frame of coordinates and use them instead.

Here is a completely non-reproducible example from a postgresql function using pl/r and rgdal / igraph packages

# match coordinates locations with network vertices

poss <- match(V(nlis.graph)$label, nlis.locations$shortcode)
V(nlis.graph)$long <- nlis.locations$longitude[poss]
V(nlis.graph)$lat <- nlis.locations$latitude[poss]
V(nlis.graph)$name <- nlis.locations$name[poss]

# create the layout matrix

latex <- matrix(c(V(nlis.graph)$long, V(nlis.graph)$lat), ncol=2)

# plot background map

plot(aust, xlim=c(110,150), ylim = c(-40, -10), border='dark green')

# plot graph - note the layout parameter and rescale = F - also edge.curved if you really want to look like the airline magazines

plot(nlis.graph, layout=latex, vertex.label.family='sans', vertex.size=v.size, vertex.label.cex=2/3, vertex.label.color='black', vertex.frame.color='black', vertex.color='white', edge.arrow.size=1/2, edge.color=gray(0.5), edge.curved=0, add=TRUE, rescale=FALSE)

The rest of the code is too embarrasing to show, but this might be along the lines of what you want. 



On 16/12/2010, at 8:43 AM, Bogdan State wrote:

> Hi everyone,
> I hope I am posting on the right list. I have recently started analyzing
> some data that involves connections between people in various cities. I
> would be extremely grateful if someone could point me towards a solution for
> drawing "geographical networks" similar to the flight maps at the back of
> airline magazines (i.e. New York connects to L.A. etc.). I have looked at
> all the usual suspects so far: sp/maptools for GIS (mostly by using spplot)
> and igraph/statnet for social network analysis. None of the packages seems
> to do exactly what I need, but I hope I am wrong.
> Thanks in advance,
> Bogdan State
> PhD Student
> Department of Sociology
> Stanford University
> bstate at stanford.edu
> 	[[alternative HTML version deleted]]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

More information about the R-sig-Geo mailing list