我想制作荷兰地图,城市之间有曲线。我有两个名为df_verticles
的数据框,其中包含24个城市及其纬度/经度组合。第二个数据框叫做df
我想用来在lat / lon从组合到lat / lon到组合之间画一条曲线。
> head(df_vertices)
city AmountSessions totalkWh AmountRFID scaledAmount scaledkWh Latitude Longitude
1 Alkmaar 13608 104554.68 1326 0.07139012 0.026941910 52.63903 4.755538
2 Almere 11281 100841.42 930 0.05006999 0.025985067 52.39447 5.282043
3 Amersfoort 7719 67663.30 1198 0.06449876 0.017435647 52.15108 5.383069
4 Amstelveen 25794 236437.93 2616 0.14084204 0.060925915 52.31724 4.859266
5 Amsterdam 402365 3880744.86 18574 1.00000000 1.000000000 52.34560 4.808834
> head(df)
CityChargeSessions NextCity Amount sumkWh scaledAmount scaledkWh Latitude_from Longitude_from Latitude_to Longitude_to
1 Amsterdam Alkmaar 1058 8133.736 0.18438480 0.15480933 52.34560 4.808834 52.63903 4.755538
2 Amsterdam Almere 998 7254.133 0.17392820 0.13806786 52.34560 4.808834 52.39447 5.282043
3 Amsterdam Amersfoort 566 4977.404 0.09864064 0.09473489 52.34560 4.808834 52.15108 5.383069
4 Amsterdam Amstelveen 3724 24210.289 0.64900662 0.46079423 52.34560 4.808834 52.31724 4.859266
5 Almere Amsterdam 1034 8685.526 0.18020216 0.16531155 52.39447 5.282043 52.34560 4.808834
6 Amersfoort Amsterdam 579 4936.823 0.10090624 0.09396251 52.15108 5.383069 52.34560 4.808834
map <- get_map(location = "Schiphol", zoom = 9, source = "google")
p1 <- ggmap(map)+
geom_point(aes(x = Longitude, y = Latitude, size=scaledkWh), data = df_vertices, alpha =0.5)+
scale_size_continuous(range=c(1,30)) +
geom_segment(data=df, aes(x=Longitude_from, y=Latitude_from, xend=Longitude_to, yend=Latitude_to),
arrow=arrow(ends="first"), size= df$scaledAmount,alpha=0.75)
这是我到目前为止的输出:
正如您在上图中所看到的,有些线条重叠,这并不好看。任何人都可以帮我解释如何将它编码为城市之间的曲线。
非常感谢!