igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Maps and Networks


From: JiHO
Subject: Re: [igraph] Maps and Networks
Date: Wed, 5 Mar 2014 12:00:32 +0100

On Thu, Feb 27, 2014 at 12:20 PM, Lorenzo Isella
<address@hidden> wrote:
> Apologies for posting this to two different mailing lists, but I really need
> some cross expertise.
> I am trying to do the following: plot a geographical map colored according
> to a scalar value (choropleth map) and to overimpose a network on the map.
> To fix the ideas, you can imagine that I am plotting the GDP in different
> countries (choropleth map) and the flow of payments among them (here is
> where the network kicks in).

The code at the end of the email is a little too long for me to test
it but as long as your map data is in lat lon, it should to be
difficult to do what you want, and keep everything in lat lon.

Basically you need

map_data <- read.shp(...)
map_data <- fortify(map_data)

network_data <- read.table(...)

# now both map_data and network_data have columns lat and lon
# the question is really how your network data is formated. The
best/easiest would be with 5 columns: startLon, startLat, endLon,
endLat, amount

ggplot() +
  geom_polygon(aes(x=lon, y=lat, fill=...), data=map_data) +
  geom_segment(aes(x=startLon, y=startLat, xend=endLon, yend=endLat,
size=amount), data=network_data)

Jean-Olivier Irisson
—
Université Pierre et Marie Curie
Laboratoire d'Océanographie de Villefranche
181 Chemin du Lazaret 06230 Villefranche-sur-Mer
Tel: +33 04 93 76 38 04
Mob: +33 06 21 05 19 90
http://www.obs-vlfr.fr/~irisson/
Send me large files at: http://www.obs-vlfr.fr/~irisson/upload/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]