I am looking for a way to add more information to this Origin-Destinatio plot. First i would like to add a label to each of the zones (origin/ destination). Secondly, I would also like to plot a map as a background and possibly add a color gradient to the plot.
Example datasets are included in the package stplanR. I use a different dataset. This is my code so far:
library(stplanr)
library(tidyverse)
library(sp)
Cents <- read.table(...)
str(Cents)
head(Cents)
coords <- Cents[,c("lat","lon")]
data <- as.data.frame( Cents[,1])
crs <- CRS("+init=epsg:28992") # proj4string of coords
Centssp <- SpatialPointsDataFrame(coords = coords,
data = data,
proj4string = crs)
Flows <- read.table(...)
l <- od2line(flow = Flows, zones = Centssp)
l
plot(l, lwd = l$MotorisedTraffic / 5)`
Thanks in advance!
edit: code with example datasets
l <- od2line(flow = flow, zones = cents)
l
# remove lines with no length
plot(l, lwd = l$All / 5 )```
To add a map to the background, try