いよいよ、歩行空間ネットワークをPythonで読み込んでいきます。これができるようになると、ネットワーク分析をするにあたり、RhinocerosとPythonを自由に行き来できるようになります。
前回は、Rhinocerosでモデリングした歩行空間ネットワークを.txtで書き出しました。
→RhinocerosでモデリングしたネットワークをPythonで読み込む②
本記事では、そのファイルをPythonで隣接配列に再構築します。
目標
- Rhinocerosでネットワークを描く
- Rhinocerosで描いたネットワークをPythonで読み込めるように書き出す
- 書き出したファイルをPythonで読み込んで隣接配列を作る
本記事では第3項に取り組みます。
本記事の内容は、.txtをどう扱うかに終始するため、ネットワーク分析の本筋からは外れます。しかし、これができずにネットワーク分析をあきらめてしまう学生を多く見てきたので、そのような悲しいことが起こらないように、一連の記事の締めくくりとして説明したいと思います。
ファイルの読み込みとデータの再構築
前回作ったファイルは隣接配列(adjacentList.txt)、属性(attributeList.txt)、座標(coordinations.txt)の三種類です。それぞれの中身と、所望のデータ構造にするためのコードについて見ていきましょう。
隣接配列
adjacentList.txtは次のようなテキストです。
adjacentList.txt
0
1,3,4,
1
0,2,27,
2
1,
3
0,
4
0,5,10,
5
4,9,7,
6
7,
7
6,8,5,
8
7,
9
5,
10
4,39,64,
11
12,
12
11,14,27,
13
14,
14
13,15,12,
15
14,
16
17,
17
16,19,20,
18
19,
19
18,17,21,
20
17,59,60,
21
19,23,30,
22
23,
23
22,21,31,
24
25,26,28,
25
24,61,64,
26
24,27,60,
27
26,12,1,
28
24,29,30,
29
28,58,61,
30
21,28,60,
31
23,32,36,
32
31,
33
34,
34
33,36,47,
35
36,
36
35,34,31,
37
38,
38
37,39,46,
39
38,10,62,
40
41,
41
40,42,44,
42
41,56,62,
43
44,
44
43,46,41,
45
46,
46
45,38,44,
47
34,48,
48
47,55,58,
49
50,52,56,
50
49,
51
52,
52
51,53,49,
53
52,54,55,
54
53,
55
48,53,57,
56
49,42,57,65,
57
55,56,58,65,
58
57,48,29,
59
20,
60
20,26,30,
61
29,25,63,
62
39,42,66,
63
61,64,65,66,
64
25,10,63,
65
57,56,63,66,
66
65,63,62,
このように、adjacentList.txtは、
ノードの番号_i_
_i_の隣接ノード1の番号, _i_の隣接ノード2の番号, ..., _i_の隣接ノードnの番号,
の繰り返しになっています(というよりも、そのように書き出しました)。したがって、adjacentList.txtを順番に読み込んだ際に、奇数行目をkey、偶数行目をカンマ区切りでリスト化したものをvalueにすれば、隣接配列が再構築できるわけです。
これを実現するコードが以下になります。
adjacentList = {}
f = open("C:\\Users\\Owner\\Desktop\\adjacentList.txt", "r")
cnt = 1
for l in f:
if cnt % 2 == 1:
target = int(l)
else:
neis = l.rstrip("\n").split(",")
neighbors = []
for i in range(len(neis)-1):
neighbors.append(int(neis[i]))
adjacentList[target] = neighbors
cnt += 1
f.close()
print(adjacentList)
結果
{0: [1, 3, 4], 1: [0, 2, 27], 2: [1], 3: [0], 4: [0, 5, 10], 5: [4, 9, 7], 6: [7], 7: [6, 8, 5], 8: [7], 9: [5], 10: [4, 39, 64], 11: [12], 12: [11, 14, 27], 13: [14], 14: [13, 15, 12], 15: [14], 16: [17], 17: [16, 19, 20], 18: [19], 19: [18, 17, 21], 20: [17, 59, 60], 21: [19, 23, 30], 22: [23], 23: [22, 21, 31], 24: [25, 26, 28], 25: [24, 61, 64], 26: [24, 27, 60], 27: [26, 12, 1], 28: [24, 29, 30], 29: [28, 58, 61], 30: [21, 28, 60], 31: [23, 32, 36], 32: [31], 33: [34], 34: [33, 36, 47], 35: [36], 36: [35, 34, 31], 37: [38], 38: [37, 39, 46], 39: [38, 10, 62], 40: [41], 41: [40, 42, 44], 42: [41, 56, 62], 43: [44], 44: [43, 46, 41], 45: [46], 46: [45, 38, 44], 47: [34, 48], 48: [47, 55, 58], 49: [50, 52, 56], 50: [49], 51: [52], 52: [51, 53, 49], 53: [52, 54, 55], 54: [53], 55: [48, 53, 57], 56: [49, 42, 57, 65], 57: [55, 56, 58, 65], 58: [57, 48, 29], 59: [20], 60: [20, 26, 30], 61: [29, 25, 63], 62: [39, 42, 66], 63: [61, 64, 65, 66], 64: [25, 10, 63], 65: [57, 56, 63, 66], 66: [65, 63, 62]}
属性
attributeList.txtは次のようなテキストです。
adjacentList.txt
0
11.1074033249
network::crosswalk
14.8220751918
network::street
8.61537806501
network::street
_
1
11.1074033249
network::crosswalk
14.0744954367
network::street
3.95438837971
network::street
_
2
14.0744954367
network::street
_
3
14.8220751918
network::street
_
4
8.61537806501
network::street
48.2886157329
network::street
9.17188538270
network::crosswalk
_
5
48.2886157329
network::street
38.2320244198
network::street
6.97422800317
network::crosswalk
_
6
40.3569306817
network::street
_
7
40.3569306817
network::street
15.3391958646
network::street
6.97422800317
network::crosswalk
_
8
15.3391958646
network::street
_
9
38.2320244198
network::street
_
10
9.17188538270
network::crosswalk
49.1429730022
network::street
2.00298106587
network::street
_
11
14.7349112166
network::street
_
12
14.7349112166
network::street
6.00447373329
network::crosswalk
67.1804616121
network::street
_
13
14.7930810004
network::street
_
14
14.7930810004
network::street
11.5591537855
network::street
6.00447373329
network::crosswalk
_
15
11.5591537855
network::street
_
16
10.5419208643
network::street
_
17
10.5419208643
network::street
4.09407392038
network::crosswalk
39.2181710352
network::street
_
18
10.5671080962
network::street
_
19
10.5671080962
network::street
4.09407392038
network::crosswalk
38.9582224218
network::street
_
20
39.2181710352
network::street
10.3003819330
network::street
8.22728202026
network::crosswalk
_
21
38.9582224218
network::street
5.83857121526
network::street
8.74848798352
network::crosswalk
_
22
5.93624890305
network::street
_
23
5.93624890305
network::street
5.83857121526
network::street
15.4510120333
network::crosswalk
_
24
10.7772181147
network::crosswalk
4.73207293592
network::street
94.7302103075
network::street
_
25
10.7772181147
network::crosswalk
73.6539359760
network::street
7.25940897404
network::street
_
26
4.73207293592
network::street
12.1531970184
network::crosswalk
61.2110001514
network::street
_
27
12.1531970184
network::crosswalk
67.1804616121
network::street
3.95438837971
network::street
_
28
94.7302103075
network::street
9.718645919
network::crosswalk
9.38343949814
network::street
_
29
9.718645919
network::crosswalk
8.03452453354
network::street
22.7713890855
network::street
_
30
8.74848798352
network::crosswalk
9.38343949814
network::street
82.5846309517
network::street
_
31
15.4510120333
network::crosswalk
5.11688760372
network::street
6.68887011579
network::street
_
32
5.11688760372
network::street
_
33
41.4590394290
network::street
_
34
41.4590394290
network::street
9.29237197423
network::crosswalk
6.90711619475
network::street
_
35
41.8832149564
network::street
_
36
41.8832149564
network::street
9.29237197423
network::crosswalk
6.68887011579
network::street
_
37
14.8342074603
network::street
_
38
14.8342074603
network::street
9.59916809269
network::crosswalk
50.4814441178
network::street
_
39
9.59916809269
network::crosswalk
49.1429730022
network::street
82.6287670373
network::street
_
40
28.5748595052
network::street
_
41
28.5748595052
network::street
8.68658703253
network::crosswalk
51.1282514133
network::street
_
42
8.68658703253
network::crosswalk
26.5439265585
network::street
26.8233221519
network::street
_
43
22.1203390311
network::street
_
44
22.1203390311
network::street
8.20061629523
network::crosswalk
51.1282514133
network::street
_
45
21.1566509723
network::street
_
46
21.1566509723
network::street
50.4814441178
network::street
8.20061629523
network::crosswalk
_
47
6.90711619475
network::street
11.4459529225
network::street
_
48
11.4459529225
network::street
42.2319342080
network::street
16.0155420529
network::crosswalk
_
49
31.9962915471
network::street
5.66253116804
network::street
15.5603119385
network::crosswalk
_
50
31.9962915471
network::street
_
51
9.92586057028
network::street
_
52
9.92586057028
network::street
25.4074153103
network::crosswalk
5.66253116804
network::street
_
53
25.4074153103
network::crosswalk
20.1797182359
network::street
4.47301902413
network::street
_
54
20.1797182359
network::street
_
55
42.2319342080
network::street
4.47301902413
network::street
16.0158455236
network::crosswalk
_
56
15.5603119385
network::crosswalk
26.5439265585
network::street
31.6330587708
network::street
19.8124701576
network::street
_
57
16.0158455236
network::crosswalk
31.6330587708
network::street
42.1919163230
network::street
21.1866298608
network::street
_
58
42.1919163230
network::street
16.0155420529
network::crosswalk
8.03452453354
network::street
_
59
10.3003819330
network::street
_
60
8.22728202026
network::crosswalk
61.2110001514
network::street
82.5846309517
network::street
_
61
22.7713890855
network::street
73.6539359760
network::street
47.7318942765
network::street
_
62
82.6287670373
network::street
26.8233221519
network::street
13.4918015112
network::street
_
63
47.7318942765
network::street
79.7521068203
network::street
18.4889931821
network::street
34.3333101162
network::street
_
64
7.25940897404
network::street
2.00298106587
network::street
79.7521068203
network::street
_
65
21.1866298608
network::street
19.8124701576
network::street
18.4889931821
network::street
24.1678872496
network::street
_
66
24.1678872496
network::street
34.3333101162
network::street
13.4918015112
network::street
_
adjacentList.txtよりも少しわかりにくいですが、attributeList.txtは、
ノードの番号_i_
_i_と隣接ノード1間のエッジの長さ
_i_と隣接ノード1間のエッジのレイヤー名
_i_と隣接ノード2間のエッジの長さ
_i_と隣接ノード2間のエッジのレイヤー名
...
_i_と隣接ノード_n_間のエッジの長さ
_i_と隣接ノード_n_間のエッジのレイヤー名
_(アンダーバー)
の繰り返しです。注目するノードと、そのノードを端点に持つエッジをかたまりとして、その切れ目をアンダーバーで明示しています。
アンダーバーの直後は、注目するノードの番号であり、keyとして保持します。その後、アンダーバーが再び出てくるまで、[長さ, レイヤー名]を順番に作り、それらをリスト化したものをvalueとすれば、隣接配列と順序が対応した、エッジの属性を格納する辞書型のデータが得られます。
これを実現するコードが以下になります。
attributeList = {}
f = open("C:\\Users\\Owner\\Desktop\\attributeList.txt", "r")
cnt = 1
nex = True
for l in f:
if l == "_\n":
attributeList[target] = edges
nex = True
continue
if nex:
target = int(l.rstrip("\n"))
nex = False
edge_attr = [] # edge_attr = [length, category]
edges = [] # edges = [[length, category], [length, category],....]
cnt = 1
continue
else:
if cnt % 2 == 1:
edge_attr.append(float(l.rstrip("\n"))) # length is appended
cnt += 1
elif cnt % 2 == 0:
edge_attr.append(l.rstrip("\n")) # category is appended
edges.append(edge_attr)
edge_attr = []
cnt += 1
f.close()
print(attributeList)
結果
{0: [[11.1074033249, 'network::crosswalk'], [14.8220751918, 'network::street'], [8.61537806501, 'network::street']], 1: [[11.1074033249, 'network::crosswalk'], [14.0744954367, 'network::street'], [3.95438837971, 'network::street']], 2: [[14.0744954367, 'network::street']], 3: [[14.8220751918, 'network::street']], 4: [[8.61537806501, 'network::street'], [48.2886157329, 'network::street'], [9.1718853827, 'network::crosswalk']], 5: [[48.2886157329, 'network::street'], [38.2320244198, 'network::street'], [6.97422800317, 'network::crosswalk']], 6: [[40.3569306817, 'network::street']], 7: [[40.3569306817, 'network::street'], [15.3391958646, 'network::street'], [6.97422800317, 'network::crosswalk']], 8: [[15.3391958646, 'network::street']], 9: [[38.2320244198, 'network::street']], 10: [[9.1718853827, 'network::crosswalk'], [49.1429730022, 'network::street'], [2.00298106587, 'network::street']], 11: [[14.7349112166, 'network::street']], 12: [[14.7349112166, 'network::street'], [6.00447373329, 'network::crosswalk'], [67.1804616121, 'network::street']], 13: [[14.7930810004, 'network::street']], 14: [[14.7930810004, 'network::street'], [11.5591537855, 'network::street'], [6.00447373329, 'network::crosswalk']], 15: [[11.5591537855, 'network::street']], 16: [[10.5419208643, 'network::street']], 17: [[10.5419208643, 'network::street'], [4.09407392038, 'network::crosswalk'], [39.2181710352, 'network::street']], 18: [[10.5671080962, 'network::street']], 19: [[10.5671080962, 'network::street'], [4.09407392038, 'network::crosswalk'], [38.9582224218, 'network::street']], 20: [[39.2181710352, 'network::street'], [10.300381933, 'network::street'], [8.22728202026, 'network::crosswalk']], 21: [[38.9582224218, 'network::street'], [5.83857121526, 'network::street'], [8.74848798352, 'network::crosswalk']], 22: [[5.93624890305, 'network::street']], 23: [[5.93624890305, 'network::street'], [5.83857121526, 'network::street'], [15.4510120333, 'network::crosswalk']], 24: [[10.7772181147, 'network::crosswalk'], [4.73207293592, 'network::street'], [94.7302103075, 'network::street']], 25: [[10.7772181147, 'network::crosswalk'], [73.653935976, 'network::street'], [7.25940897404, 'network::street']], 26: [[4.73207293592, 'network::street'], [12.1531970184, 'network::crosswalk'], [61.2110001514, 'network::street']], 27: [[12.1531970184, 'network::crosswalk'], [67.1804616121, 'network::street'], [3.95438837971, 'network::street']], 28: [[94.7302103075, 'network::street'], [9.718645919, 'network::crosswalk'], [9.38343949814, 'network::street']], 29: [[9.718645919, 'network::crosswalk'], [8.03452453354, 'network::street'], [22.7713890855, 'network::street']], 30: [[8.74848798352, 'network::crosswalk'], [9.38343949814, 'network::street'], [82.5846309517, 'network::street']], 31: [[15.4510120333, 'network::crosswalk'], [5.11688760372, 'network::street'], [6.68887011579, 'network::street']], 32: [[5.11688760372, 'network::street']], 33: [[41.459039429, 'network::street']], 34: [[41.459039429, 'network::street'], [9.29237197423, 'network::crosswalk'], [6.90711619475, 'network::street']], 35: [[41.8832149564, 'network::street']], 36: [[41.8832149564, 'network::street'], [9.29237197423, 'network::crosswalk'], [6.68887011579, 'network::street']], 37: [[14.8342074603, 'network::street']], 38: [[14.8342074603, 'network::street'], [9.59916809269, 'network::crosswalk'], [50.4814441178, 'network::street']], 39: [[9.59916809269, 'network::crosswalk'], [49.1429730022, 'network::street'], [82.6287670373, 'network::street']], 40: [[28.5748595052, 'network::street']], 41: [[28.5748595052, 'network::street'], [8.68658703253, 'network::crosswalk'], [51.1282514133, 'network::street']], 42: [[8.68658703253, 'network::crosswalk'], [26.5439265585, 'network::street'], [26.8233221519, 'network::street']], 43: [[22.1203390311, 'network::street']], 44: [[22.1203390311, 'network::street'], [8.20061629523, 'network::crosswalk'], [51.1282514133, 'network::street']], 45: [[21.1566509723, 'network::street']], 46: [[21.1566509723, 'network::street'], [50.4814441178, 'network::street'], [8.20061629523, 'network::crosswalk']], 47: [[6.90711619475, 'network::street'], [11.4459529225, 'network::street']], 48: [[11.4459529225, 'network::street'], [42.231934208, 'network::street'], [16.0155420529, 'network::crosswalk']], 49: [[31.9962915471, 'network::street'], [5.66253116804, 'network::street'], [15.5603119385, 'network::crosswalk']], 50: [[31.9962915471, 'network::street']], 51: [[9.92586057028, 'network::street']], 52: [[9.92586057028, 'network::street'], [25.4074153103, 'network::crosswalk'], [5.66253116804, 'network::street']], 53: [[25.4074153103, 'network::crosswalk'], [20.1797182359, 'network::street'], [4.47301902413, 'network::street']], 54: [[20.1797182359, 'network::street']], 55: [[42.231934208, 'network::street'], [4.47301902413, 'network::street'], [16.0158455236, 'network::crosswalk']], 56: [[15.5603119385, 'network::crosswalk'], [26.5439265585, 'network::street'], [31.6330587708, 'network::street'], [19.8124701576, 'network::street']], 57: [[16.0158455236, 'network::crosswalk'], [31.6330587708, 'network::street'], [42.191916323, 'network::street'], [21.1866298608, 'network::street']], 58: [[42.191916323, 'network::street'], [16.0155420529, 'network::crosswalk'], [8.03452453354, 'network::street']], 59: [[10.300381933, 'network::street']], 60: [[8.22728202026, 'network::crosswalk'], [61.2110001514, 'network::street'], [82.5846309517, 'network::street']], 61: [[22.7713890855, 'network::street'], [73.653935976, 'network::street'], [47.7318942765, 'network::street']], 62: [[82.6287670373, 'network::street'], [26.8233221519, 'network::street'], [13.4918015112, 'network::street']], 63: [[47.7318942765, 'network::street'], [79.7521068203, 'network::street'], [18.4889931821, 'network::street'], [34.3333101162, 'network::street']], 64: [[7.25940897404, 'network::street'], [2.00298106587, 'network::street'], [79.7521068203, 'network::street']], 65: [[21.1866298608, 'network::street'], [19.8124701576, 'network::street'], [18.4889931821, 'network::street'], [24.1678872496, 'network::street']], 66: [[24.1678872496, 'network::street'], [34.3333101162, 'network::street'], [13.4918015112, 'network::street']]}
座標
coordinations.txtは次のようなテキストです。
adjacentList.txt
68.9577325423
142.299807799
0.0
57.8753839319
143.045433643
0.0
59.0087545228
157.074221648
0.0
70.1454229038
157.074221648
0.0
73.7082078155
135.112477009
0.0
119.285945763
119.160667926
0.0
130.866333434
157.074221648
0.0
125.923869619
117.021083126
0.0
140.491336154
112.216934032
0.0
124.210388409
157.074221648
0.0
70.6015116756
126.482765509
0.0
-13.0847619715
157.074221648
0.0
-13.2559413252
142.340304783
0.0
-19.0899969033
157.074221648
0.0
-19.2601331305
142.282119054
0.0
-30.8187441791
142.170106276
0.0
-30.8187441791
92.7081720102
0.0
-20.2771545042
92.7917341848
0.0
-30.8187441791
88.6133189720
0.0
-20.2519732914
88.6977377056
0.0
-20.5183717202
132.009163392
0.0
-20.0123549282
49.7402521950
0.0
-30.8187441791
46.0626319844
0.0
-24.9025750130
46.5504776955
0.0
51.2355683215
127.788248237
0.0
61.5316533595
124.604058673
0.0
48.9198465834
131.914983884
0.0
53.9213659634
142.991310065
0.0
-1.88652901847
49.3544830648
0.0
6.88099405302
45.1613198567
0.0
-11.2697419494
49.4196897191
0.0
-25.7238995001
31.1213105456
0.0
-30.8187441791
30.6468672442
0.0
-9.92271249931
-14.2358586851
0.0
-10.7312752910
27.2152954193
0.0
-19.0935861117
-14.2358586851
0.0
-20.0140625572
27.6372402950
0.0
140.491336154
103.485124302
0.0
126.400392855
108.121828725
0.0
117.282188618
111.122225293
0.0
140.491336154
-11.6592682786
0.0
113.985301460
-0.984404318991
0.0
105.927624844
2.26069072088
0.0
140.491336154
42.0853777844
0.0
119.765832483
49.8160243571
0.0
140.491336154
50.5055515990
0.0
120.692989497
57.9640601630
0.0
-4.15791286976
29.3364179067
0.0
6.45922029186
25.0601670098
0.0
75.2547126670
-2.15882358227
0.0
104.884223225
-14.2358586851
0.0
67.1304719519
-14.2358586851
0.0
70.2533057857
-4.81404267612
0.0
46.8031631466
4.96489197722
0.0
40.5941211849
-14.2358586851
0.0
45.6330725865
9.28215815751
0.0
81.3054831974
12.1768481359
0.0
51.9626633982
23.9941800441
0.0
12.8254491750
39.7560411606
0.0
-30.8187441791
132.023133854
0.0
-12.2910972672
131.998004686
0.0
19.7870581607
63.9221745849
0.0
108.710277274
28.9392861996
0.0
64.2052947234
46.4477935691
0.0
68.6401653709
126.076497342
0.0
72.3273288929
29.8382953877
0.0
96.1551076071
33.8785596931
0.0
coordinations.txtは、
ノード_i_の_x_座標
ノード_i_の_y_座標
ノード_i_の_z_座標
の繰り返しです。ですから、3行ずつまとまりを作れば、そのノードの座標が得られます。今回は、すべてのノードが z = 0 の平面上にあるので、z 座標は省略します。
実際のコードが以下になります。
coordinations = []
f = open("C:\\Users\\Owner\\Desktop\\coordinations.txt", "r")
cnt = 1
coordination = []
for l in f:
if cnt % 3 == 0:
coordinations.append(coordination)
coordination = []
else:
coordination.append(float(l.rstrip("\n")))
cnt += 1
f.close()
print(coordinations)
結果
[[68.9577325423, 142.299807799], [57.8753839319, 143.045433643], [59.0087545228, 157.074221648], [70.1454229038, 157.074221648], [73.7082078155, 135.112477009], [119.285945763, 119.160667926], [130.866333434, 157.074221648], [125.923869619, 117.021083126], [140.491336154, 112.216934032], [124.210388409, 157.074221648], [70.6015116756, 126.482765509], [-13.0847619715, 157.074221648], [-13.2559413252, 142.340304783], [-19.0899969033, 157.074221648], [-19.2601331305, 142.282119054], [-30.8187441791, 142.170106276], [-30.8187441791, 92.7081720102], [-20.2771545042, 92.7917341848], [-30.8187441791, 88.613318972], [-20.2519732914, 88.6977377056], [-20.5183717202, 132.009163392], [-20.0123549282, 49.740252195], [-30.8187441791, 46.0626319844], [-24.902575013, 46.5504776955], [51.2355683215, 127.788248237], [61.5316533595, 124.604058673], [48.9198465834, 131.914983884], [53.9213659634, 142.991310065], [-1.88652901847, 49.3544830648], [6.88099405302, 45.1613198567], [-11.2697419494, 49.4196897191], [-25.7238995001, 31.1213105456], [-30.8187441791, 30.6468672442], [-9.92271249931, -14.2358586851], [-10.731275291, 27.2152954193], [-19.0935861117, -14.2358586851], [-20.0140625572, 27.637240295], [140.491336154, 103.485124302], [126.400392855, 108.121828725], [117.282188618, 111.122225293], [140.491336154, -11.6592682786], [113.98530146, -0.984404318991], [105.927624844, 2.26069072088], [140.491336154, 42.0853777844], [119.765832483, 49.8160243571], [140.491336154, 50.505551599], [120.692989497, 57.964060163], [-4.15791286976, 29.3364179067], [6.45922029186, 25.0601670098], [75.254712667, -2.15882358227], [104.884223225, -14.2358586851], [67.1304719519, -14.2358586851], [70.2533057857, -4.81404267612], [46.8031631466, 4.96489197722], [40.5941211849, -14.2358586851], [45.6330725865, 9.28215815751], [81.3054831974, 12.1768481359], [51.9626633982, 23.9941800441], [12.825449175, 39.7560411606], [-30.8187441791, 132.023133854], [-12.2910972672, 131.998004686], [19.7870581607, 63.9221745849], [108.710277274, 28.9392861996], [64.2052947234, 46.4477935691], [68.6401653709, 126.076497342], [72.3273288929, 29.8382953877], [96.1551076071, 33.8785596931]]
まとめ
Rhinocerosでネットワークについて書き出した.txtデータをPythonで読み込み、使えるデータ構造に再構築する方法を紹介しました。.txtデータの作り方は、これが正解というわけではなく、自分が取り回しやすい形なら、なんでも大丈夫です。そして、再構築に必要なコードも、.txtデータの作り方に依存します。また、.txtに書き出しているので、読み込む言語はPythonでなくても、なんでも大丈夫です。
プログラミングに不慣れな人の中には、「なんでも大丈夫」と言われると、逆に不安になるかもしれません。しかし、簡単なコードの組み合わせでできるので、紹介したコードを参考に挑戦してみてほしいです。
全体のまとめ
一連の記事に関連するコードは、以下にあります。
→関連するコード
RhinocerosでモデリングしたネットワークをPythonで読み込む①
、RhinocerosでモデリングしたネットワークをPythonで読み込む②、そして、本記事を通して、RhinocerosでモデリングしたネットワークをPythonで分析できるようになりました。ネットワークのデータさえできてしまえば、そこからは自分のオリジナリティを発揮する、楽しいフェーズが待っています。ネットワーク分析には様々な手法、観点があり、また、ネットワーク上でシミュレーションを行うといった方向性もあります。それらを駆使して、建築・都市計画数理の面白さの一端を感じていただければ幸いですし、これからも、実践的な情報の発信に努めます。
ホームページのご案内
建築・都市計画数理に関する私の研究の内容や、研究にまつわるtips等は、個人ホームページにて公開しています。ゆくゆくは、気軽に使える分析ツールも作っていきたいと思っているので、ぜひ覗きに来てください。
→田端祥太の個人ホームページ