In [1]:
%matplotlib inline
In [2]:
import numpy as np
import pandas as pd
In [3]:
df = pd.read_csv("/Users/celine/Desktop/5DataVisual/google_transit/shapes.txt")
In [6]:
df
Out[6]:
shape_id
shape_pt_lat
shape_pt_lon
shape_pt_sequence
shape_dist_traveled
0
[@2.0.86175868@]34
40.114158
-88.173105
0
0.000000
1
[@2.0.86175868@]34
40.114158
-88.173106
1
0.134184
2
[@2.0.86175868@]34
40.114171
-88.173107
2
1.560577
3
[@2.0.86175868@]34
40.114186
-88.173108
3
3.228456
4
[@2.0.86175868@]34
40.114200
-88.173109
4
4.787531
5
[@2.0.86175868@]34
40.114215
-88.173112
5
6.471524
6
[@2.0.86175868@]34
40.114220
-88.173112
6
7.024778
7
[@2.0.86175868@]34
40.114225
-88.173113
7
7.594072
8
[@2.0.86175868@]34
40.114231
-88.173114
8
8.271667
9
[@2.0.86175868@]34
40.114236
-88.173115
9
8.832998
10
[@2.0.86175868@]34
40.114241
-88.173116
10
9.402292
11
[@2.0.86175868@]34
40.114247
-88.173118
11
10.086498
12
[@2.0.86175868@]34
40.114252
-88.173119
12
10.655792
13
[@2.0.86175868@]34
40.114258
-88.173119
13
11.326711
14
[@2.0.86175868@]34
40.114267
-88.173119
14
12.326358
15
[@2.0.86175868@]34
40.114276
-88.173118
15
13.330497
16
[@2.0.86175868@]34
40.114285
-88.173117
16
14.334637
17
[@2.0.86175868@]34
40.114295
-88.173115
17
15.457300
18
[@2.0.86175868@]34
40.114306
-88.173112
18
16.701669
19
[@2.0.86175868@]34
40.114318
-88.173108
19
18.076644
20
[@2.0.86175868@]34
40.114330
-88.173104
20
19.451619
21
[@2.0.86175868@]34
40.114341
-88.173100
21
20.721058
22
[@2.0.86175868@]34
40.114363
-88.173093
22
23.238569
23
[@2.0.86175868@]34
40.114385
-88.173086
23
25.754292
24
[@2.0.86175868@]34
40.114407
-88.173080
24
28.252058
25
[@2.0.86175868@]34
40.114429
-88.173072
25
30.789161
26
[@2.0.86175868@]34
40.114446
-88.173067
26
32.724388
27
[@2.0.86175868@]34
40.114464
-88.173062
27
34.770416
28
[@2.0.86175868@]34
40.114482
-88.173055
28
36.857827
29
[@2.0.86175868@]34
40.114706
-88.173081
29
61.849180
...
...
...
...
...
...
1415569
[@15.0.64613606@]1
40.142010
-88.192242
2309
10719.321470
1415570
[@15.0.64613606@]1
40.142010
-88.192176
2310
10724.927560
1415571
[@15.0.64613606@]1
40.142011
-88.192110
2311
10730.534453
1415572
[@15.0.64613606@]1
40.142011
-88.192043
2312
10736.225808
1415573
[@15.0.64613606@]1
40.142011
-88.191977
2313
10741.832701
1415574
[@15.0.64613606@]1
40.142011
-88.191942
2314
10744.806016
1415575
[@15.0.64613606@]1
40.142011
-88.191907
2315
10747.779331
1415576
[@15.0.64613606@]1
40.142010
-88.191871
2316
10750.839192
1415577
[@15.0.64613606@]1
40.142010
-88.191836
2317
10753.810993
1415578
[@15.0.64613606@]1
40.142010
-88.191801
2318
10756.782793
1415579
[@15.0.64613606@]1
40.142010
-88.191766
2319
10759.754594
1415580
[@15.0.64613606@]1
40.142009
-88.191731
2320
10762.727909
1415581
[@15.0.64613606@]1
40.142009
-88.191695
2321
10765.786299
1415582
[@15.0.64613606@]1
40.142009
-88.191620
2322
10772.158265
1415583
[@15.0.64613606@]1
40.142010
-88.191544
2323
10778.615839
1415584
[@15.0.64613606@]1
40.142011
-88.191469
2324
10784.987804
1415585
[@15.0.64613606@]1
40.142012
-88.191393
2325
10791.445379
1415586
[@15.0.64613606@]1
40.142012
-88.191359
2326
10794.335787
1415587
[@15.0.64613606@]1
40.142012
-88.191325
2327
10797.226195
1415588
[@15.0.64613606@]1
40.142012
-88.191291
2328
10800.116603
1415589
[@15.0.64613606@]1
40.142013
-88.191257
2329
10803.007010
1415590
[@15.0.64613606@]1
40.142014
-88.191223
2330
10805.897418
1415591
[@15.0.64613606@]1
40.142014
-88.191189
2331
10808.784710
1415592
[@15.0.64613606@]1
40.142015
-88.191155
2332
10811.675118
1415593
[@15.0.64613606@]1
40.142015
-88.191121
2333
10814.562409
1415594
[@15.0.64613606@]1
40.142014
-88.191098
2334
10816.516155
1415595
[@15.0.64613606@]1
40.142013
-88.191076
2335
10818.387526
1415596
[@15.0.64613606@]1
40.142012
-88.191053
2336
10820.343575
1415597
[@15.0.64613606@]1
40.142011
-88.191040
2337
10821.482162
1415598
[@15.0.64613606@]1
40.141982
-88.191041
2338
10824.741476
1415599 rows × 5 columns
In [40]:
df2=df.groupby('shape_id')
In [41]:
group
Out[41]:
shape_id
shape_pt_lat
shape_pt_lon
shape_pt_sequence
shape_dist_traveled
217077
[@2.0.86232218@]426
40.093620
-88.269847
0
0.000000
217078
[@2.0.86232218@]426
40.093612
-88.269878
1
2.822648
217079
[@2.0.86232218@]426
40.093664
-88.269892
2
8.766249
217080
[@2.0.86232218@]426
40.093739
-88.269909
3
17.225153
217081
[@2.0.86232218@]426
40.093732
-88.269986
4
23.817253
217082
[@2.0.86232218@]426
40.093726
-88.270062
5
30.312360
217083
[@2.0.86232218@]426
40.093721
-88.270139
6
36.881888
217084
[@2.0.86232218@]426
40.093717
-88.270216
7
43.443188
217085
[@2.0.86232218@]426
40.093713
-88.270295
8
50.174483
217086
[@2.0.86232218@]426
40.093709
-88.270374
9
56.905109
217087
[@2.0.86232218@]426
40.093707
-88.270453
10
63.625026
217088
[@2.0.86232218@]426
40.093706
-88.270533
11
70.426835
217089
[@2.0.86232218@]426
40.093705
-88.270581
12
74.508979
217090
[@2.0.86232218@]426
40.093705
-88.270629
13
78.590021
217091
[@2.0.86232218@]426
40.093706
-88.270676
14
82.586357
217092
[@2.0.86232218@]426
40.093706
-88.270724
15
86.667398
217093
[@2.0.86232218@]426
40.093706
-88.270772
16
90.748440
217094
[@2.0.86232218@]426
40.093706
-88.270820
17
94.829481
217095
[@2.0.86232218@]426
40.093706
-88.270868
18
98.910522
217096
[@2.0.86232218@]426
40.093706
-88.270916
19
102.991564
217097
[@2.0.86232218@]426
40.093707
-88.270980
20
108.450389
217098
[@2.0.86232218@]426
40.093737
-88.270980
21
111.802299
217099
[@2.0.86232218@]426
40.093707
-88.270980
22
115.154210
217100
[@2.0.86232218@]426
40.093707
-88.271024
23
118.877660
217101
[@2.0.86232218@]426
40.093707
-88.271050
24
121.084565
217102
[@2.0.86232218@]426
40.093707
-88.271077
25
123.377500
217103
[@2.0.86232218@]426
40.093707
-88.271104
26
125.670434
217104
[@2.0.86232218@]426
40.093707
-88.271131
27
127.963368
217105
[@2.0.86232218@]426
40.093707
-88.271183
28
132.383294
217106
[@2.0.86232218@]426
40.093707
-88.271234
29
136.717867
...
...
...
...
...
...
220322
[@2.0.86232218@]426
40.130493
-88.182923
3245
16070.222412
220323
[@2.0.86232218@]426
40.130526
-88.182870
3246
16076.031192
220324
[@2.0.86232218@]426
40.130559
-88.182816
3247
16081.905471
220325
[@2.0.86232218@]426
40.130592
-88.182763
3248
16087.713476
220326
[@2.0.86232218@]426
40.130625
-88.182710
3249
16093.522256
220327
[@2.0.86232218@]426
40.130643
-88.182682
3250
16096.631732
220328
[@2.0.86232218@]426
40.130660
-88.182654
3251
16099.667966
220329
[@2.0.86232218@]426
40.130678
-88.182625
3252
16102.841916
220330
[@2.0.86232218@]426
40.130696
-88.182597
3253
16105.951393
220331
[@2.0.86232218@]426
40.130714
-88.182569
3254
16109.060869
220332
[@2.0.86232218@]426
40.130731
-88.182541
3255
16112.097103
220333
[@2.0.86232218@]426
40.130749
-88.182512
3256
16115.271053
220334
[@2.0.86232218@]426
40.130767
-88.182484
3257
16118.380530
220335
[@2.0.86232218@]426
40.130781
-88.182461
3258
16120.876493
220336
[@2.0.86232218@]426
40.130794
-88.182438
3259
16123.306666
220337
[@2.0.86232218@]426
40.130808
-88.182415
3260
16125.802629
220338
[@2.0.86232218@]426
40.130822
-88.182392
3261
16128.298592
220339
[@2.0.86232218@]426
40.130836
-88.182370
3262
16130.730616
220340
[@2.0.86232218@]426
40.130850
-88.182347
3263
16133.228382
220341
[@2.0.86232218@]426
40.130864
-88.182324
3264
16135.724345
220342
[@2.0.86232218@]426
40.130878
-88.182301
3265
16138.220309
220343
[@2.0.86232218@]426
40.130892
-88.182279
3266
16140.652332
220344
[@2.0.86232218@]426
40.130906
-88.182256
3267
16143.151900
220345
[@2.0.86232218@]426
40.130920
-88.182234
3268
16145.583924
220346
[@2.0.86232218@]426
40.130934
-88.182212
3269
16148.015948
220347
[@2.0.86232218@]426
40.130948
-88.182190
3270
16150.446120
220348
[@2.0.86232218@]426
40.130962
-88.182168
3271
16152.878144
220349
[@2.0.86232218@]426
40.130976
-88.182145
3272
16155.375910
220350
[@2.0.86232218@]426
40.130984
-88.182132
3273
16156.770389
220351
[@2.0.86232218@]426
40.130972
-88.182125
3274
16158.221809
3275 rows × 5 columns
In [46]:
import matplotlib.pyplot as plt
import numpy as np
# from matplotlib import cm
mycolor=plt.cm.jet
color_id=np.linspace(0,1,677)
s=0
for name, group in df2:
s=s+1
# print(name)
#group.plot('shape_pt_lat','shape_pt_lon')
plt.plot(group['shape_pt_lon'],group['shape_pt_lat'], color=plt.cm.binary(s/677), alpha = 0.2)
plt.show()
This graph describe the physical path for every vehicle takes. Data are latitudes and longitudes of points from shapes.txt, grouped by shape_id. Paths covered Champaign and Urbana, and denser in campus district.
Content source: yingjun2/project-spring2017
Similar notebooks: