Reputation: 170
I have a transaction data at country level.
Data Sample:
TransID CountryOrigin(CO) CountryDestination(CD) COLat COLong CDLat CDLong
1 India Australia 20.593684 78.962880 -25.274398 133.775136
Now i want to link the Country origin and destination with the number of transactions.If the transaction is high then the width of the line will be bigger than the low transaction zone.
I want the visualization more similar to below image (With the country name label in worldmap)
Upvotes: 1
Views: 384
Reputation: 6516
I am not quite sure, but as far as I understand you are looking for something like this: http://flowingdata.com/2011/05/11/how-to-map-connections-with-great-circles/
If you want the width of the line bigger in higher transaction zones, you have to set the lwd parameter
higher in these lines:
#Load packages
install.packages("maps")
install.packages("geosphere")
library(maps)
library(geosphere)
#Create a Map
xlim <- c(55.593, 140.9628)
ylim <- c(-30.2743, 40.775)
map("world", col="#f2f2f2", fill=TRUE, bg="white", lwd=0.05, xlim=xlim, ylim=ylim)
#create a line
lat_india <- 20.5936
lon_india <- 78.96288
lat_aussie <- -25.2743
lon_aussie <- 133.77
inter <- gcIntermediate(c(lon_india, lat_india), c(lon_aussie, lat_aussie), n=50, addStartEnd=TRUE)
#plot the line (lwd represents the width of the line)
lines(inter, lwd=3)
Upvotes: 2