我正在研究R中的通勤旅行模式(起点 - 目的地)流程图。我所拥有的数据是通勤者(Date,Card,Entry_lat,Entry_Long,Exit_Lat,Exit_Long)
的每日交易。旅行路径可能类似(因为他们通勤上班)。
我需要在map (great circles)
中绘制这个。
如果原点&目的地是相同的 - 连接线的不间断应该表示相同的Origin -destination。
structure(list(business_date = structure(c(17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245,
17245, 17245, 17245, 17245, 17245, 17245, 17245, 17245), class = "Date"),
token_id = c(1.12374e+19, 1.12374e+19, 1.81313e+19, 1.85075e+19,
1.30752e+19, 1.30752e+19, 1.32828e+19, 1.70088e+19, 1.70088e+19,
1.70088e+19, 1.05536e+19, 1.44818e+19, 1.44736e+19, 1.44736e+19,
1.44736e+19, 1.44736e+19, 1.89909e+19, 1.15795e+19, 1.15795e+19,
1.15795e+19, 1.70234e+19, 1.70234e+19, 1.44062e+19, 1.21512e+19,
1.21512e+19, 1.95909e+19, 1.95909e+19, 1.50179e+19, 1.50179e+19,
1.24174e+19, 1.36445e+19, 1.98549e+19, 1.92068e+19, 1.18468e+19,
1.18468e+19, 1.92409e+19, 1.92409e+19, 1.21387e+19, 1.9162e+19,
1.9162e+19, 1.40385e+19, 1.40385e+19, 1.32996e+19, 1.32996e+19,
1.69103e+19, 1.69103e+19, 1.57387e+19, 1.40552e+19, 1.40552e+19,
1.00302e+19, 1.43084e+19, 1.15233e+19, 1.88848e+19, 1.19599e+19,
1.96302e+19, 1.21535e+19, 1.21535e+19, 1.68518e+19, 1.68518e+19,
1.68518e+19, 1.37427e+19, 1.37427e+19, 1.04737e+19, 1.90085e+19,
1.90085e+19, 1.43879e+19, 1.43879e+19, 1.95948e+19, 1.95948e+19,
1.77371e+19, 1.77371e+19, 1.05398e+19, 1.05398e+19, 1.61873e+19,
1.61873e+19, 1.61873e+19, 1.75773e+19, 1.75773e+19, 1.26304e+19,
1.6716e+19, 1.6716e+19, 1.66425e+19, 1.66425e+19, 1.05765e+19,
1.05765e+19, 1.52111e+19, 1.38387e+19, 1.38387e+19, 1.8251e+19,
1.07627e+19, 1.07627e+19, 1.42453e+19, 1.67648e+19, 1.67648e+19,
1.67648e+19, 1.67648e+19, 1.36642e+19, 1.84325e+19, 1.09845e+19,
1.09845e+19, 1.07256e+19, 1.45155e+19, 1.53534e+19, 1.53534e+19,
1.84093e+19, 1.84093e+19, 1.94052e+19, 1.44263e+19, 1.44263e+19,
1.92014e+19, 1.92014e+19, 1.05822e+19, 1.05822e+19, 1.94361e+19,
1.69123e+19, 1.69123e+19, 1.86672e+19, 1.75637e+19, 1.67081e+19,
1.67081e+19, 1.52689e+19, 1.00154e+19, 1.28014e+19, 1.38625e+19,
1.74426e+19, 1.73024e+19, 1.10039e+19, 1.07579e+19, 1.07579e+19,
1.95868e+19, 1.95868e+19, 1.71153e+19, 1.71153e+19, 1.05466e+19,
1.65159e+19, 1.0462e+19, 1.65034e+19, 1.65034e+19, 1.27579e+19,
1.27579e+19, 1.47069e+19, 1.93883e+19, 1.93883e+19, 1.16625e+19,
1.81929e+19, 1.81929e+19, 1.43785e+19, 1.43785e+19, 1.34872e+19,
1.21872e+19, 1.62546e+19, 1.62546e+19, 1.1874e+19, 1.1874e+19,
1.83859e+19, 1.38549e+19, 1.38549e+19, 1.46911e+19, 1.46911e+19,
1.46911e+19, 1.25183e+19, 1.84413e+19, 1.84413e+19, 1.54549e+19,
1.45863e+19, 1.00699e+19, 1.3154e+19, 1.3154e+19, 1.3154e+19,
1.29877e+19, 1.29877e+19, 1.12276e+19, 1.12276e+19, 1.72559e+19,
1.72559e+19, 1.26689e+19, 1.26689e+19, 1.32528e+19, 1.90638e+19,
1.90638e+19, 1.27811e+19, 1.27893e+19, 1.8248e+19, 1.28817e+19,
1.28817e+19, 1.00584e+19, 1.80136e+19, 1.80136e+19, 1.80136e+19,
1.66803e+19, 1.66803e+19, 1.92668e+19, 1.74647e+19, 1.74647e+19,
1.1993e+19, 1.55979e+19, 1.55979e+19, 1.31993e+19, 1.31993e+19,
1.43821e+19), Entry_Station_Lat = c(1.31509, 1.33261, 1.28425,
1.31812, 1.33858, 1.29287, 1.39692, 1.37773, 1.33858, 1.33322,
1.28179, 1.30036, 1.43697, 1.39752, 1.27637, 1.39752, 1.41747,
1.35733, 1.28405, 1.37773, 1.35898, 1.42948, 1.32774, 1.42948,
1.349, 1.36017, 1.34971, 1.38451, 1.31509, 1.31509, 1.37002,
1.34971, 1.31231, 1.39169, 1.31812, 1.44909, 1.29341, 1.41747,
1.33759, 1.44062, 1.31509, 1.38451, 1.29461, 1.32388, 1.41747,
1.27614, 1.39752, 1.39449, 1.33261, 1.31231, 1.30694, 1.32725,
1.42948, 1.34037, 1.31812, 1.36017, 1.33322, 1.42948, 1.3205,
1.37002, 1.31188, 1.39449, 1.41747, 1.349, 1.35733, 1.44062,
1.32774, 1.44909, 1.32774, 1.32104, 1.33858, 1.40455, 1.33322,
1.35146, 1.28405, 1.29287, 1.39147, 1.39169, 1.38451, 1.38269,
1.32774, 1.35339, 1.31509, 1.40524, 1.39628, 1.32573, 1.31231,
1.30694, 1.34426, 1.37773, 1.37773, 1.40455, 1.44062, 1.28405,
1.29287, 1.28405, 1.31654, 1.34971, 1.33764, 1.32774, 1.37773,
1.34037, 1.44909, 1.44062, 1.30252, 1.31509, 1.37121, 1.39752,
1.34426, 1.3115, 1.28405, 1.34037, 1.29974, 1.26563, 1.30036,
1.27935, 1.38814, 1.37121, 1.29461, 1.32388, 1.37773, 1.28932,
1.31509, 1.42948, 1.30723, 1.32388, 1.35339, 1.349, 1.33155,
1.34426, 1.33155, 1.39752, 1.33322, 1.31812, 1.26563, 1.35146,
1.38178, 1.43256, 1.30723, 1.29287, 1.29872, 1.31509, 1.33858,
1.35146, 1.41747, 1.29341, 1.40524, 1.29694, 1.30723, 1.39752,
1.34857, 1.27646, 1.44909, 1.3205, 1.35339, 1.38777, 1.37773,
1.37773, 1.30036, 1.37773, 1.29341, 1.32104, 1.33261, 1.34971,
1.32774, 1.30036, 1.35898, 1.28425, 1.28405, 1.30736, 1.35733,
1.349, 1.33858, 1.35339, 1.28135, 1.30252, 1.33322, 1.39169,
1.33858, 1.34225, 1.31231, 1.30036, 1.31812, 1.37121, 1.31188,
1.34426, 1.37121, 1.30036, 1.39169, 1.31139, 1.33759, 1.349,
1.3625, 1.31167, 1.39752, 1.44062, 1.43697, 1.31977, 1.37304,
1.38672), Entry_Station_Long = c(103.76525, 103.84718, 103.84329,
103.89308, 103.70611, 103.8526, 103.90902, 103.76339, 103.70611,
103.74217, 103.859, 103.85563, 103.7865, 103.74745, 103.84596,
103.74745, 103.83298, 103.9884, 103.85152, 103.76339, 103.75191,
103.83505, 103.67828, 103.83505, 103.74956, 103.88504, 103.87326,
103.74437, 103.76525, 103.76525, 103.84955, 103.87326, 103.83793,
103.89548, 103.89308, 103.82004, 103.78479, 103.83298, 103.69742,
103.80098, 103.76525, 103.74437, 103.80605, 103.93002, 103.83298,
103.79156, 103.74745, 103.90051, 103.84718, 103.83793, 103.84973,
103.94638, 103.83505, 103.84673, 103.89308, 103.88504, 103.74217,
103.83505, 103.84387, 103.84955, 103.85436, 103.90051, 103.83298,
103.74956, 103.9884, 103.80098, 103.67828, 103.82004, 103.67828,
103.91296, 103.70611, 103.90208, 103.74217, 103.84921, 103.85152,
103.8526, 103.90597, 103.89548, 103.74437, 103.76237, 103.67828,
103.94522, 103.76525, 103.9086, 103.8938, 103.80745, 103.83793,
103.84973, 103.72092, 103.76339, 103.76339, 103.90208, 103.80098,
103.85152, 103.8526, 103.85152, 103.88296, 103.87326, 103.83953,
103.67828, 103.76339, 103.84673, 103.82004, 103.80098, 103.79836,
103.76525, 103.89237, 103.74745, 103.72092, 103.87135, 103.85152,
103.84673, 103.78744, 103.82152, 103.85563, 103.85267, 103.90537,
103.89237, 103.80605, 103.93002, 103.76339, 103.81703, 103.76525,
103.83505, 103.79036, 103.93002, 103.94522, 103.74956, 103.86896,
103.72092, 103.86896, 103.74745, 103.74217, 103.89308, 103.82152,
103.84921, 103.84496, 103.774, 103.79036, 103.8526, 103.84612,
103.76525, 103.70611, 103.84921, 103.83298, 103.78479, 103.9086,
103.85092, 103.79036, 103.74745, 103.83974, 103.85452, 103.82004,
103.84387, 103.94522, 103.7696, 103.76339, 103.76339, 103.85563,
103.76339, 103.78479, 103.91296, 103.84718, 103.87326, 103.67828,
103.85563, 103.75191, 103.84329, 103.85152, 103.86275, 103.9884,
103.74956, 103.70611, 103.94522, 103.8391, 103.79836, 103.74217,
103.89548, 103.70611, 103.73274, 103.83793, 103.85563, 103.89308,
103.89237, 103.85436, 103.72092, 103.89237, 103.85563, 103.89548,
103.77866, 103.69742, 103.74956, 103.76893, 103.79631, 103.74745,
103.80098, 103.7865, 103.9031, 103.94929, 103.89054), Exit_Station_Lat = structure(c(48L,
34L, 118L, 60L, 14L, 54L, 10L, 49L, 49L, 74L, 71L, 65L, 102L,
5L, 102L, 119L, 116L, 10L, 13L, 88L, 117L, 66L, 40L, 62L,
117L, 37L, 67L, 34L, 85L, 44L, 102L, 44L, 115L, 29L, 92L,
17L, 121L, 70L, 120L, 52L, 85L, 34L, 42L, 11L, 4L, 115L,
62L, 48L, 92L, 14L, 54L, 72L, 49L, 40L, 67L, 49L, 67L, 40L,
70L, 117L, 96L, 33L, 14L, 65L, 62L, 45L, 120L, 49L, 121L,
54L, 41L, 49L, 107L, 10L, 14L, 10L, 92L, 91L, 49L, 45L, 81L,
34L, 44L, 92L, 92L, 7L, 40L, 107L, 49L, 8L, 77L, 92L, 10L,
14L, 10L, 117L, 45L, 58L, 60L, 53L, 14L, 49L, 48L, 121L,
34L, 23L, 25L, 60L, 102L, 10L, 31L, 21L, 48L, 110L, 7L, 33L,
54L, 94L, 44L, 18L, 5L, 43L, 10L, 10L, 60L, 45L, 10L, 102L,
37L, 47L, 60L, 49L, 102L, 44L, 89L, 80L, 118L, 119L, 14L,
38L, 109L, 52L, 34L, 64L, 17L, 115L, 19L, 109L, 121L, 28L,
7L, 70L, 40L, 121L, 5L, 45L, 88L, 61L, 28L, 88L, 92L, 25L,
41L, 91L, 60L, 5L, 10L, 7L, 66L, 65L, 34L, 54L, 62L, 5L,
42L, 49L, 34L, 91L, 119L, 54L, 70L, 54L, 41L, 33L, 67L, 45L,
5L, 92L, 82L, 52L, 30L, 49L, 32L, 68L, 34L, 119L, 120L, 72L,
38L, 92L), .Label = c("1.27082", "1.27091", "1.27236", "1.27614",
"1.27637", "1.27646", "1.27935", "1.28221", "1.28247", "1.28405",
"1.28621", "1.28819", "1.28932", "1.29287", "1.29309", "1.29338",
"1.29341", "1.29461", "1.29694", "1.29959", "1.29974", "1.30034",
"1.30252", "1.30287", "1.30392", "1.30394", "1.30619", "1.30736",
"1.30842", "1.31139", "1.3115", "1.31167", "1.31188", "1.31509",
"1.31654", "1.31756", "1.31913", "1.31977", "1.32008", "1.3205",
"1.32104", "1.32388", "1.32573", "1.32725", "1.32774", "1.33119",
"1.33155", "1.33261", "1.33322", "1.33474", "1.33554", "1.33759",
"1.33764", "1.33858", "1.33921", "1.34037", "1.34225", "1.34293",
"1.3432", "1.34426", "1.34857", "1.349", "1.34905", "1.35158",
"1.35733", "1.35898", "1.36017", "1.3625", "1.36849", "1.37002",
"1.37121", "1.37304", "1.37666", "1.37775", "1.3786", "1.37862",
"1.38001", "1.38029", "1.3803", "1.38178", "1.38269", "1.38295",
"1.38399", "1.38423", "1.38451", "1.38671", "1.38672", "1.38777",
"1.38814", "1.3894", "1.39147", "1.39169", "1.39189", "1.39208",
"1.39389", "1.39449", "1.39452", "1.39628", "1.39692", "1.39717",
"1.39732", "1.39752", "1.39821", "1.39928", "1.39962", "1.4023",
"1.40455", "1.40511", "1.40524", "1.40843", "1.40961", "1.41184",
"1.41588", "1.41685", "1.41747", "1.42526", "1.42948", "1.43256",
"1.43697", "1.44062", "1.44909"), class = "factor"), Exit_Station_Long = structure(c(59L,
19L, 27L, 4L, 65L, 3L, 63L, 6L, 6L, 21L, 93L, 121L, 9L, 56L,
9L, 32L, 16L, 63L, 44L, 23L, 50L, 12L, 54L, 11L, 50L, 71L,
87L, 19L, 7L, 118L, 9L, 118L, 49L, 90L, 96L, 31L, 45L, 61L,
38L, 2L, 7L, 19L, 117L, 47L, 34L, 49L, 11L, 59L, 96L, 65L,
3L, 119L, 6L, 54L, 87L, 6L, 87L, 54L, 61L, 50L, 101L, 67L,
65L, 121L, 11L, 1L, 38L, 6L, 45L, 3L, 114L, 6L, 102L, 63L,
65L, 63L, 96L, 107L, 6L, 1L, 17L, 19L, 118L, 96L, 96L, 66L,
54L, 102L, 6L, 60L, 26L, 96L, 63L, 65L, 63L, 50L, 1L, 82L,
4L, 52L, 65L, 6L, 59L, 45L, 19L, 37L, 48L, 4L, 9L, 63L, 78L,
33L, 59L, 99L, 66L, 67L, 3L, 83L, 118L, 40L, 56L, 41L, 63L,
63L, 4L, 1L, 63L, 9L, 71L, 76L, 4L, 6L, 9L, 118L, 106L, 55L,
27L, 32L, 65L, 104L, 110L, 2L, 19L, 74L, 31L, 49L, 62L, 110L,
45L, 72L, 66L, 61L, 54L, 45L, 56L, 1L, 23L, 53L, 72L, 23L,
96L, 48L, 114L, 107L, 4L, 56L, 63L, 66L, 12L, 121L, 19L,
3L, 11L, 56L, 117L, 6L, 19L, 107L, 32L, 3L, 61L, 3L, 114L,
67L, 87L, 1L, 56L, 96L, 94L, 2L, 28L, 6L, 35L, 22L, 19L,
32L, 38L, 119L, 104L, 96L), .Label = c("103.67828", "103.69742",
"103.70611", "103.72092", "103.73274", "103.74217", "103.74437",
"103.74529", "103.74745", "103.74905", "103.74956", "103.75191",
"103.7537", "103.75803", "103.76011", "103.76215", "103.76237",
"103.76449", "103.76525", "103.76648", "103.76667", "103.76893",
"103.7696", "103.77082", "103.77145", "103.77266", "103.774",
"103.77866", "103.78185", "103.78425", "103.78479", "103.7865",
"103.78744", "103.79156", "103.79631", "103.79654", "103.79836",
"103.80098", "103.803", "103.80605", "103.80745", "103.80781",
"103.80978", "103.81703", "103.82004", "103.82592", "103.82695",
"103.83216", "103.83298", "103.83505", "103.83918", "103.83953",
"103.83974", "103.84387", "103.84496", "103.84596", "103.84673",
"103.84674", "103.84718", "103.84823", "103.84955", "103.85092",
"103.85152", "103.85226", "103.8526", "103.85267", "103.85436",
"103.85446", "103.85452", "103.86088", "103.86149", "103.86275",
"103.86291", "103.86395", "103.86405", "103.86896", "103.87087",
"103.87135", "103.87534", "103.87563", "103.8763", "103.87971",
"103.88003", "103.88126", "103.88243", "103.88296", "103.88504",
"103.8858", "103.88816", "103.8886", "103.88934", "103.89054",
"103.89237", "103.89313", "103.8938", "103.89548", "103.89719",
"103.89723", "103.89854", "103.9003", "103.90051", "103.90208",
"103.90214", "103.9031", "103.90484", "103.90537", "103.90597",
"103.90599", "103.90663", "103.9086", "103.90902", "103.9126",
"103.9127", "103.91296", "103.91616", "103.9165", "103.93002",
"103.94638", "103.94929", "103.95337", "103.9884"), class = "factor")), .Names = c("business_date",
"token_id", "Entry_Station_Lat", "Entry_Station_Long", "Exit_Station_Lat",
"Exit_Station_Long"), row.names = c(10807L, 10808L, 10810L, 10815L,
10817L, 10818L, 10819L, 10820L, 10823L, 10824L, 10826L, 10827L,
10829L, 10831L, 10832L, 10833L, 10834L, 10835L, 10836L, 10838L,
10840L, 10841L, 10843L, 10847L, 10850L, 10852L, 10854L, 10855L,
10859L, 10861L, 10869L, 10872L, 10883L, 10886L, 10891L, 10895L,
10896L, 10897L, 10900L, 10902L, 10903L, 10906L, 10910L, 10911L,
10912L, 10913L, 10915L, 10920L, 10921L, 10924L, 10928L, 10929L,
10933L, 10935L, 10944L, 10948L, 10949L, 10951L, 10952L, 10955L,
10957L, 10958L, 10960L, 10961L, 10962L, 10963L, 10966L, 10967L,
10969L, 10971L, 10972L, 10976L, 10977L, 10978L, 10979L, 10980L,
10982L, 10983L, 10984L, 10986L, 10989L, 10990L, 10993L, 10994L,
10995L, 10996L, 10998L, 11000L, 11002L, 11005L, 11008L, 11009L,
11011L, 11012L, 11013L, 11014L, 11015L, 11021L, 11024L, 11025L,
11029L, 11030L, 11032L, 11034L, 11035L, 11037L, 11038L, 11039L,
11041L, 11042L, 11043L, 11044L, 11045L, 11047L, 11050L, 11051L,
11054L, 11058L, 11062L, 11066L, 11067L, 11071L, 11074L, 11076L,
11077L, 11080L, 11082L, 11084L, 11085L, 11089L, 11091L, 11093L,
11096L, 11098L, 11101L, 11103L, 11105L, 11106L, 11108L, 11109L,
11111L, 11112L, 11115L, 11119L, 11120L, 11121L, 11122L, 11123L,
11125L, 11126L, 11127L, 11128L, 11129L, 11132L, 11134L, 11136L,
11138L, 11140L, 11142L, 11146L, 11149L, 11151L, 11152L, 11155L,
11158L, 11161L, 11164L, 11166L, 11167L, 11168L, 11169L, 11171L,
11172L, 11174L, 11175L, 11179L, 11180L, 11192L, 11194L, 11195L,
11198L, 11203L, 11206L, 11207L, 11208L, 11210L, 11213L, 11216L,
11217L, 11219L, 11222L, 11225L, 11227L, 11228L, 11230L, 11233L,
11234L, 11235L, 11240L, 11241L), class = "data.frame")
我在Flow map(Travel Path) Using Lat and Long in R
提出了类似的问题我已经通过GeoSpheres
,但无法获得视觉上吸引人的旅行模式。
是否可以通过计算出发地和目的地之间的总行程来实现此Flow-MAp Graph。或
或
到目前为止使用的内容:(参考SO)
require(ggplot2)
require(ggmap)
basemap <- get_map("Singapore",
source = "stamen",
maptype = "toner",
zoom = 11)
g = ggplot(a)
map = ggmap(basemap, base_layer = g)
map = map + coord_cartesian() +
geom_curve(size = 1.3,
aes(x=as.numeric(Entry_Station_Long),
y=as.numeric(Entry_Station_Lat),
xend=as.numeric(as.character(Exit_Station_Long)),
yend=as.numeric(as.character(Exit_Station_Lat))
))
map