GPSフライトログのCSVファイルをもとに、simplekmlを使ってGoogleEarthで飛行機のパイロット目線の映像を作るPythonプログラムについて説明する
はじめに
フライトログのCSVファイルをもとに、simplekmlを使ってGoogleEarthに飛行軌跡をプロットするPythonプログラムについて説明する
最終的にはこんな感じになる
GPSデータからGoogle Earthでフライト映像
— いーそー (@mtk_birdman) March 2, 2023
下手にGoPro使うよりも視野が広くてわかりやすい気がする pic.twitter.com/9UGykViiEq
↓使用するCSVファイルはこれ
longitude | latitude | press_alt | |
0 | 2.561264 | 49.02319 | 0 |
1 | 2.561197 | 49.02318 | -0.74282 |
2 | 2.561117 | 49.02318 | -1.09067 |
3 | 2.561022 | 49.02318 | -0.91195 |
4 | 2.560911 | 49.02318 | -0.07291 |
5 | 2.560783 | 49.02319 | 1.558092 |
6 | 2.560636 | 49.02319 | 4.10623 |
7 | 2.560469 | 49.02319 | 7.685852 |
8 | 2.560282 | 49.0232 | 12.39631 |
9 | 2.560075 | 49.0232 | 18.31815 |
10 | 2.559847 | 49.02321 | 25.50977 |
11 | 2.559599 | 49.02321 | 34.00473 |
12 | 2.559332 | 49.02321 | 43.80982 |
13 | 2.559047 | 49.0232 | 54.90391 |
14 | 2.558746 | 49.02319 | 67.23769 |
15 | 2.55843 | 49.02318 | 80.73434 |
16 | 2.558102 | 49.02316 | 95.29103 |
17 | 2.557765 | 49.02314 | 110.7813 |
18 | 2.55742 | 49.02311 | 127.0579 |
19 | 2.557071 | 49.02308 | 143.9571 |
20 | 2.55672 | 49.02304 | 161.3022 |
21 | 2.556369 | 49.02301 | 178.9084 |
22 | 2.556022 | 49.02297 | 196.5876 |
23 | 2.555679 | 49.02293 | 214.1533 |
24 | 2.555342 | 49.0229 | 231.4247 |
25 | 2.555014 | 49.02287 | 248.2316 |
26 | 2.554694 | 49.02284 | 264.4177 |
27 | 2.554384 | 49.02283 | 279.8445 |
28 | 2.554083 | 49.02282 | 294.3936 |
29 | 2.553792 | 49.02283 | 307.9685 |
30 | 2.553509 | 49.02285 | 320.4962 |
31 | 2.553234 | 49.02288 | 331.9272 |
32 | 2.552965 | 49.02293 | 342.2353 |
33 | 2.552701 | 49.023 | 351.4167 |
34 | 2.55244 | 49.02308 | 359.488 |
35 | 2.55218 | 49.02317 | 366.4843 |
36 | 2.55192 | 49.02328 | 372.4565 |
37 | 2.551659 | 49.02339 | 377.4686 |
38 | 2.551394 | 49.02352 | 381.5941 |
39 | 2.551125 | 49.02366 | 384.9137 |
40 | 2.550851 | 49.02379 | 387.5116 |
41 | 2.550571 | 49.02393 | 389.4731 |
42 | 2.550285 | 49.02407 | 390.8818 |
43 | 2.549993 | 49.0242 | 391.8177 |
44 | 2.549695 | 49.02433 | 392.3552 |
45 | 2.549393 | 49.02444 | 392.5617 |
46 | 2.549087 | 49.02455 | 392.4969 |
47 | 2.548777 | 49.02464 | 392.2123 |
48 | 2.548467 | 49.02472 | 391.7511 |
49 | 2.548155 | 49.02479 | 391.1485 |
50 | 2.547845 | 49.02485 | 390.4324 |
51 | 2.547536 | 49.02489 | 389.6243 |
52 | 2.547231 | 49.02492 | 388.74 |
53 | 2.546928 | 49.02494 | 387.7913 |
54 | 2.54663 | 49.02496 | 386.7866 |
55 | 2.546337 | 49.02497 | 385.732 |
56 | 2.546048 | 49.02499 | 384.6329 |
57 | 2.545763 | 49.025 | 383.494 |
58 | 2.545483 | 49.02503 | 382.3205 |
59 | 2.545205 | 49.02506 | 381.1182 |
60 | 2.544931 | 49.02511 | 379.8943 |
61 | 2.544659 | 49.02517 | 378.6567 |
62 | 2.544389 | 49.02524 | 377.4146 |
63 | 2.54412 | 49.02534 | 376.1777 |
64 | 2.543853 | 49.02546 | 374.9561 |
65 | 2.543587 | 49.02559 | 373.7599 |
66 | 2.543323 | 49.02575 | 372.5983 |
67 | 2.543062 | 49.02593 | 371.4798 |
68 | 2.542805 | 49.02612 | 370.4114 |
69 | 2.542555 | 49.02633 | 369.3982 |
70 | 2.542313 | 49.02656 | 368.4433 |
71 | 2.542082 | 49.0268 | 367.5479 |
72 | 2.541865 | 49.02704 | 366.7109 |
73 | 2.541665 | 49.0273 | 365.9294 |
74 | 2.541486 | 49.02755 | 365.1989 |
75 | 2.54133 | 49.02781 | 364.5136 |
76 | 2.541202 | 49.02806 | 363.8667 |
77 | 2.541104 | 49.02831 | 363.2513 |
78 | 2.541038 | 49.02855 | 362.6603 |
79 | 2.541007 | 49.02877 | 362.0872 |
80 | 2.541013 | 49.02899 | 361.5266 |
81 | 2.541057 | 49.02919 | 360.9743 |
82 | 2.541138 | 49.02938 | 360.4276 |
83 | 2.541256 | 49.02955 | 359.8852 |
84 | 2.54141 | 49.02971 | 359.3476 |
85 | 2.541599 | 49.02985 | 358.8167 |
86 | 2.541818 | 49.02997 | 358.2956 |
87 | 2.542066 | 49.03008 | 357.7884 |
88 | 2.542337 | 49.03017 | 357.2996 |
89 | 2.542628 | 49.03025 | 356.8337 |
90 | 2.542935 | 49.03031 | 356.395 |
91 | 2.543252 | 49.03037 | 355.9868 |
92 | 2.543575 | 49.03041 | 355.6112 |
93 | 2.5439 | 49.03044 | 355.2688 |
94 | 2.544222 | 49.03047 | 354.9585 |
95 | 2.544538 | 49.03049 | 354.6773 |
96 | 2.544845 | 49.0305 | 354.4201 |
97 | 2.54514 | 49.03051 | 354.1803 |
98 | 2.545421 | 49.03051 | 353.9499 |
99 | 2.545688 | 49.03051 | 353.7193 |
100 | 2.54594 | 49.03051 | 353.4786 |
101 | 2.546178 | 49.03051 | 353.2174 |
102 | 2.546402 | 49.0305 | 352.9258 |
103 | 2.546614 | 49.0305 | 352.5947 |
104 | 2.546817 | 49.0305 | 352.2161 |
105 | 2.547012 | 49.0305 | 351.7841 |
106 | 2.547202 | 49.0305 | 351.2947 |
107 | 2.547389 | 49.0305 | 350.7463 |
108 | 2.547577 | 49.03051 | 350.14 |
109 | 2.547768 | 49.03052 | 349.4793 |
110 | 2.547963 | 49.03054 | 348.7699 |
111 | 2.548165 | 49.03056 | 348.0199 |
112 | 2.548376 | 49.03058 | 347.2389 |
113 | 2.548595 | 49.03061 | 346.4379 |
114 | 2.548823 | 49.03064 | 345.6284 |
115 | 2.54906 | 49.03067 | 344.8222 |
116 | 2.549307 | 49.03071 | 344.0305 |
117 | 2.54956 | 49.03074 | 343.2636 |
118 | 2.549821 | 49.03078 | 342.5299 |
119 | 2.550086 | 49.03081 | 341.8362 |
120 | 2.550355 | 49.03085 | 341.1865 |
121 | 2.550625 | 49.03088 | 340.5825 |
122 | 2.550895 | 49.0309 | 340.0233 |
123 | 2.551164 | 49.03093 | 339.5051 |
124 | 2.55143 | 49.03094 | 339.0222 |
125 | 2.551692 | 49.03096 | 338.5664 |
126 | 2.551949 | 49.03096 | 338.1283 |
127 | 2.552201 | 49.03096 | 337.6969 |
128 | 2.552448 | 49.03096 | 337.2612 |
129 | 2.552691 | 49.03095 | 336.8099 |
130 | 2.552928 | 49.03094 | 336.3326 |
131 | 2.553162 | 49.03092 | 335.8198 |
132 | 2.553394 | 49.03091 | 335.2641 |
133 | 2.553623 | 49.0309 | 334.6598 |
134 | 2.553851 | 49.03088 | 334.0037 |
135 | 2.554078 | 49.03088 | 333.2952 |
136 | 2.554306 | 49.03088 | 332.536 |
137 | 2.554533 | 49.03089 | 331.7302 |
138 | 2.554761 | 49.03091 | 330.8841 |
139 | 2.554989 | 49.03094 | 330.0057 |
140 | 2.555215 | 49.03099 | 329.1044 |
141 | 2.555438 | 49.03105 | 328.1902 |
142 | 2.555657 | 49.03112 | 327.2736 |
143 | 2.555869 | 49.03122 | 326.3645 |
144 | 2.556072 | 49.03132 | 325.4722 |
145 | 2.556264 | 49.03145 | 324.6044 |
146 | 2.556441 | 49.03158 | 323.7674 |
147 | 2.556601 | 49.03174 | 322.9653 |
148 | 2.556742 | 49.0319 | 322.1999 |
149 | 2.55686 | 49.03208 | 321.4709 |
150 | 2.556954 | 49.03226 | 320.7759 |
151 | 2.557021 | 49.03245 | 320.1103 |
152 | 2.55706 | 49.03265 | 319.468 |
153 | 2.557071 | 49.03285 | 318.8415 |
154 | 2.557052 | 49.03304 | 318.2226 |
155 | 2.557004 | 49.03324 | 317.6026 |
156 | 2.556927 | 49.03343 | 316.9731 |
157 | 2.556823 | 49.03362 | 316.3266 |
158 | 2.556693 | 49.0338 | 315.6563 |
159 | 2.556538 | 49.03397 | 314.9574 |
160 | 2.556361 | 49.03413 | 314.2267 |
161 | 2.556165 | 49.03427 | 313.4631 |
162 | 2.555951 | 49.03441 | 312.6675 |
163 | 2.555723 | 49.03453 | 311.8429 |
164 | 2.555482 | 49.03463 | 310.9943 |
165 | 2.555231 | 49.03473 | 310.1281 |
166 | 2.554973 | 49.0348 | 309.2521 |
167 | 2.554708 | 49.03487 | 308.3748 |
168 | 2.554438 | 49.03492 | 307.5048 |
169 | 2.554165 | 49.03496 | 306.651 |
170 | 2.553889 | 49.03498 | 305.8212 |
171 | 2.553612 | 49.035 | 305.0221 |
172 | 2.553333 | 49.035 | 304.2589 |
173 | 2.553052 | 49.03499 | 303.5351 |
174 | 2.552769 | 49.03498 | 302.8519 |
175 | 2.552486 | 49.03495 | 302.2084 |
176 | 2.5522 | 49.03492 | 301.6016 |
177 | 2.551912 | 49.03489 | 301.0265 |
178 | 2.551622 | 49.03485 | 300.4763 |
179 | 2.55133 | 49.03481 | 299.9428 |
180 | 2.551035 | 49.03477 | 299.4169 |
181 | 2.550739 | 49.03473 | 298.8889 |
182 | 2.550442 | 49.03469 | 298.3491 |
183 | 2.550144 | 49.03466 | 297.7886 |
184 | 2.549846 | 49.03464 | 297.199 |
185 | 2.549548 | 49.03461 | 296.5739 |
186 | 2.549252 | 49.0346 | 295.9082 |
187 | 2.548958 | 49.0346 | 295.1991 |
188 | 2.548667 | 49.0346 | 294.4462 |
189 | 2.548379 | 49.03461 | 293.6509 |
190 | 2.548096 | 49.03463 | 292.8173 |
191 | 2.547816 | 49.03465 | 291.951 |
192 | 2.547541 | 49.03468 | 291.0596 |
193 | 2.54727 | 49.03471 | 290.1519 |
194 | 2.547003 | 49.03475 | 289.2376 |
195 | 2.54674 | 49.03479 | 288.3268 |
196 | 2.546479 | 49.03482 | 287.4293 |
197 | 2.546221 | 49.03485 | 286.5544 |
198 | 2.545964 | 49.03487 | 285.7102 |
199 | 2.545708 | 49.03488 | 284.9033 |
200 | 2.545453 | 49.03487 | 284.1383 |
201 | 2.545198 | 49.03485 | 283.418 |
202 | 2.544945 | 49.03482 | 282.7426 |
203 | 2.544692 | 49.03476 | 282.1103 |
204 | 2.544442 | 49.03469 | 281.517 |
205 | 2.544196 | 49.03459 | 280.9567 |
206 | 2.543955 | 49.03447 | 280.4218 |
207 | 2.543723 | 49.03434 | 279.9034 |
208 | 2.543501 | 49.03418 | 279.3918 |
209 | 2.543293 | 49.034 | 278.8767 |
210 | 2.543102 | 49.03381 | 278.3484 |
211 | 2.542931 | 49.03361 | 277.7975 |
212 | 2.542785 | 49.03339 | 277.2158 |
213 | 2.542666 | 49.03317 | 276.5966 |
214 | 2.542577 | 49.03294 | 275.935 |
215 | 2.542522 | 49.03271 | 275.2282 |
216 | 2.542502 | 49.03248 | 274.4755 |
217 | 2.542519 | 49.03226 | 273.6783 |
218 | 2.542574 | 49.03205 | 272.8406 |
219 | 2.542666 | 49.03185 | 271.9678 |
220 | 2.542796 | 49.03167 | 271.0675 |
221 | 2.542961 | 49.03149 | 270.1483 |
222 | 2.543159 | 49.03134 | 269.2202 |
223 | 2.543387 | 49.0312 | 268.2933 |
224 | 2.543641 | 49.03108 | 267.3783 |
225 | 2.543917 | 49.03098 | 266.4851 |
226 | 2.544209 | 49.03089 | 265.6232 |
227 | 2.544514 | 49.03082 | 264.8006 |
228 | 2.544826 | 49.03076 | 264.024 |
229 | 2.54514 | 49.03071 | 263.2984 |
230 | 2.545452 | 49.03068 | 262.6265 |
231 | 2.545758 | 49.03065 | 262.0091 |
232 | 2.546054 | 49.03063 | 261.445 |
233 | 2.546337 | 49.03062 | 260.9306 |
234 | 2.546606 | 49.03062 | 260.4607 |
235 | 2.54686 | 49.03061 | 260.0279 |
236 | 2.547098 | 49.03062 | 259.6238 |
237 | 2.547321 | 49.03062 | 259.2383 |
238 | 2.547531 | 49.03063 | 258.8608 |
239 | 2.547729 | 49.03064 | 258.4798 |
240 | 2.547919 | 49.03065 | 258.0838 |
241 | 2.548104 | 49.03066 | 257.6614 |
242 | 2.548288 | 49.03068 | 257.2018 |
243 | 2.548473 | 49.0307 | 256.6948 |
244 | 2.548663 | 49.03073 | 256.1312 |
245 | 2.548862 | 49.03075 | 255.5033 |
246 | 2.549072 | 49.03078 | 254.8048 |
247 | 2.549294 | 49.03081 | 254.0308 |
248 | 2.54953 | 49.03084 | 253.1784 |
249 | 2.549781 | 49.03086 | 252.2462 |
250 | 2.550045 | 49.03088 | 251.2349 |
251 | 2.550322 | 49.0309 | 250.1467 |
252 | 2.550609 | 49.03091 | 248.9855 |
253 | 2.550902 | 49.0309 | 247.7569 |
254 | 2.551198 | 49.03088 | 246.468 |
255 | 2.551493 | 49.03085 | 245.1271 |
256 | 2.551781 | 49.03079 | 243.7439 |
257 | 2.552057 | 49.03072 | 242.3286 |
258 | 2.552317 | 49.03063 | 240.8924 |
259 | 2.552555 | 49.03051 | 239.4471 |
260 | 2.552766 | 49.03037 | 238.0044 |
261 | 2.552947 | 49.03021 | 236.576 |
262 | 2.553094 | 49.03003 | 235.1735 |
263 | 2.553203 | 49.02983 | 233.8075 |
264 | 2.553275 | 49.02962 | 232.4879 |
265 | 2.553307 | 49.0294 | 231.2235 |
266 | 2.5533 | 49.02918 | 230.0215 |
267 | 2.553255 | 49.02895 | 228.8876 |
268 | 2.553175 | 49.02873 | 227.8254 |
269 | 2.553062 | 49.02852 | 226.8368 |
270 | 2.552921 | 49.02833 | 225.9215 |
271 | 2.552756 | 49.02816 | 225.0772 |
272 | 2.552573 | 49.02801 | 224.2995 |
273 | 2.552376 | 49.02789 | 223.582 |
274 | 2.552172 | 49.02781 | 222.9165 |
275 | 2.551966 | 49.02776 | 222.2935 |
276 | 2.551763 | 49.02774 | 221.702 |
277 | 2.551569 | 49.02777 | 221.1303 |
278 | 2.55139 | 49.02782 | 220.5662 |
279 | 2.551228 | 49.02792 | 219.9974 |
280 | 2.551088 | 49.02804 | 219.412 |
281 | 2.550973 | 49.02819 | 218.7992 |
282 | 2.550885 | 49.02836 | 218.149 |
283 | 2.550827 | 49.02854 | 217.4534 |
284 | 2.550799 | 49.02874 | 216.7063 |
285 | 2.550801 | 49.02895 | 215.9035 |
286 | 2.550833 | 49.02915 | 215.0435 |
287 | 2.550896 | 49.02934 | 214.1272 |
288 | 2.550987 | 49.02953 | 213.1575 |
289 | 2.551105 | 49.02969 | 212.1401 |
290 | 2.551249 | 49.02984 | 211.0823 |
291 | 2.551416 | 49.02997 | 209.9934 |
292 | 2.551605 | 49.03007 | 208.8839 |
293 | 2.551813 | 49.03015 | 207.765 |
294 | 2.552038 | 49.03021 | 206.6488 |
295 | 2.552278 | 49.03024 | 205.5467 |
296 | 2.552529 | 49.03026 | 204.4701 |
297 | 2.55279 | 49.03026 | 203.4289 |
298 | 2.553057 | 49.03025 | 202.4317 |
299 | 2.553329 | 49.03023 | 201.4853 |
300 | 2.553603 | 49.03021 | 200.5946 |
301 | 2.553875 | 49.0302 | 199.7621 |
302 | 2.554143 | 49.03019 | 198.9881 |
303 | 2.554404 | 49.0302 | 198.2707 |
304 | 2.554654 | 49.03022 | 197.6059 |
305 | 2.554891 | 49.03027 | 196.9882 |
306 | 2.555112 | 49.03033 | 196.4103 |
307 | 2.555312 | 49.03042 | 195.8639 |
308 | 2.555489 | 49.03054 | 195.3404 |
309 | 2.55564 | 49.03067 | 194.8306 |
310 | 2.555761 | 49.03083 | 194.3258 |
311 | 2.555852 | 49.03101 | 193.8178 |
312 | 2.555909 | 49.03119 | 193.2996 |
313 | 2.55593 | 49.03139 | 192.7653 |
314 | 2.555916 | 49.03159 | 192.2106 |
315 | 2.555865 | 49.0318 | 191.6326 |
316 | 2.555778 | 49.03199 | 191.0303 |
317 | 2.555656 | 49.03217 | 190.4039 |
318 | 2.555502 | 49.03233 | 189.7548 |
319 | 2.555317 | 49.03247 | 189.0858 |
320 | 2.555105 | 49.03259 | 188.4 |
321 | 2.55487 | 49.03267 | 187.7009 |
322 | 2.554617 | 49.03272 | 186.9921 |
323 | 2.554352 | 49.03274 | 186.2768 |
324 | 2.554079 | 49.03272 | 185.5572 |
325 | 2.553805 | 49.03266 | 184.8347 |
326 | 2.553535 | 49.03257 | 184.1096 |
327 | 2.553276 | 49.03245 | 183.3808 |
328 | 2.553033 | 49.0323 | 182.646 |
329 | 2.552811 | 49.03212 | 181.9017 |
330 | 2.552616 | 49.03193 | 181.1435 |
331 | 2.552451 | 49.03171 | 180.3666 |
332 | 2.552319 | 49.03149 | 179.5657 |
333 | 2.552225 | 49.03126 | 178.736 |
334 | 2.552168 | 49.03103 | 177.8731 |
335 | 2.552152 | 49.0308 | 176.9738 |
336 | 2.552174 | 49.03057 | 176.0367 |
337 | 2.552235 | 49.03036 | 175.062 |
338 | 2.552333 | 49.03016 | 174.0521 |
339 | 2.552467 | 49.02998 | 173.0118 |
340 | 2.552632 | 49.02982 | 171.9483 |
341 | 2.552825 | 49.02967 | 170.8709 |
342 | 2.553044 | 49.02955 | 169.7906 |
343 | 2.553283 | 49.02945 | 168.7202 |
344 | 2.55354 | 49.02936 | 167.6734 |
345 | 2.553809 | 49.02929 | 166.6641 |
346 | 2.554088 | 49.02924 | 165.7058 |
347 | 2.554373 | 49.02921 | 164.8111 |
348 | 2.55466 | 49.02919 | 163.9903 |
349 | 2.554947 | 49.02918 | 163.2515 |
350 | 2.555232 | 49.02918 | 162.5993 |
351 | 2.555512 | 49.02918 | 162.0346 |
352 | 2.555788 | 49.02919 | 161.5543 |
353 | 2.556058 | 49.02921 | 161.151 |
354 | 2.556322 | 49.02923 | 160.8132 |
355 | 2.556581 | 49.02925 | 160.5253 |
356 | 2.556835 | 49.02927 | 160.2683 |
357 | 2.557085 | 49.02929 | 160.0205 |
358 | 2.557332 | 49.02931 | 159.7581 |
359 | 2.557578 | 49.02933 | 159.4562 |
360 | 2.557824 | 49.02935 | 159.0901 |
361 | 2.558071 | 49.02938 | 158.6364 |
362 | 2.558321 | 49.0294 | 158.0737 |
363 | 2.558575 | 49.02943 | 157.3844 |
364 | 2.558833 | 49.02945 | 156.5548 |
365 | 2.559097 | 49.02948 | 155.5768 |
366 | 2.559366 | 49.02951 | 154.4475 |
367 | 2.559642 | 49.02955 | 153.1706 |
368 | 2.559923 | 49.02958 | 151.7554 |
369 | 2.560211 | 49.02962 | 150.2175 |
370 | 2.560503 | 49.02966 | 148.5778 |
371 | 2.5608 | 49.0297 | 146.862 |
372 | 2.5611 | 49.02974 | 145.0992 |
373 | 2.561404 | 49.02977 | 143.3215 |
374 | 2.561709 | 49.02981 | 141.5617 |
375 | 2.562016 | 49.02985 | 139.8529 |
376 | 2.562323 | 49.02988 | 138.2261 |
377 | 2.562629 | 49.02991 | 136.7096 |
378 | 2.562935 | 49.02993 | 135.3273 |
379 | 2.563239 | 49.02995 | 134.0976 |
380 | 2.563541 | 49.02997 | 133.0327 |
381 | 2.563842 | 49.02998 | 132.138 |
382 | 2.56414 | 49.02998 | 131.4114 |
383 | 2.564437 | 49.02998 | 130.844 |
384 | 2.564733 | 49.02997 | 130.42 |
385 | 2.565027 | 49.02996 | 130.1172 |
386 | 2.56532 | 49.02995 | 129.9085 |
387 | 2.565613 | 49.02993 | 129.7627 |
388 | 2.565906 | 49.02991 | 129.646 |
389 | 2.566199 | 49.02989 | 129.5234 |
390 | 2.566493 | 49.02987 | 129.3606 |
391 | 2.566787 | 49.02985 | 129.1252 |
392 | 2.567082 | 49.02983 | 128.7883 |
393 | 2.567377 | 49.02982 | 128.3259 |
394 | 2.567673 | 49.0298 | 127.7199 |
395 | 2.56797 | 49.02979 | 126.9587 |
396 | 2.568265 | 49.02978 | 126.0384 |
397 | 2.56856 | 49.02977 | 124.9622 |
398 | 2.568854 | 49.02977 | 123.7407 |
399 | 2.569145 | 49.02976 | 122.3911 |
400 | 2.569432 | 49.02975 | 120.9366 |
401 | 2.569716 | 49.02974 | 119.4055 |
402 | 2.569995 | 49.02973 | 117.8293 |
403 | 2.570269 | 49.02971 | 116.2418 |
404 | 2.570535 | 49.02969 | 114.6774 |
405 | 2.570795 | 49.02965 | 113.1694 |
406 | 2.571046 | 49.02961 | 111.7485 |
407 | 2.571288 | 49.02955 | 110.4418 |
408 | 2.571521 | 49.02948 | 109.2711 |
409 | 2.571743 | 49.02939 | 108.2523 |
410 | 2.571955 | 49.02928 | 107.3946 |
411 | 2.572155 | 49.02916 | 106.7001 |
412 | 2.572343 | 49.02902 | 106.1642 |
413 | 2.572519 | 49.02886 | 105.7751 |
414 | 2.572683 | 49.02868 | 105.5153 |
415 | 2.572833 | 49.02848 | 105.3616 |
416 | 2.57297 | 49.02826 | 105.2868 |
417 | 2.573092 | 49.02803 | 105.2605 |
418 | 2.5732 | 49.02779 | 105.2504 |
419 | 2.573293 | 49.02753 | 105.2241 |
420 | 2.573371 | 49.02727 | 105.1498 |
421 | 2.573432 | 49.02699 | 104.9976 |
422 | 2.573477 | 49.02672 | 104.7408 |
423 | 2.573504 | 49.02644 | 104.3564 |
424 | 2.573514 | 49.02617 | 103.8259 |
425 | 2.573506 | 49.02591 | 103.1355 |
426 | 2.573479 | 49.02565 | 102.2762 |
427 | 2.573434 | 49.0254 | 101.2434 |
428 | 2.573369 | 49.02517 | 100.0371 |
429 | 2.573286 | 49.02495 | 98.66064 |
430 | 2.573183 | 49.02475 | 97.12018 |
431 | 2.573061 | 49.02457 | 95.42404 |
432 | 2.572921 | 49.02441 | 93.58165 |
433 | 2.572763 | 49.02427 | 91.60278 |
434 | 2.572588 | 49.02414 | 89.49672 |
435 | 2.572395 | 49.02404 | 87.27171 |
436 | 2.572188 | 49.02396 | 84.93443 |
437 | 2.571965 | 49.02389 | 82.48972 |
438 | 2.57173 | 49.02383 | 79.94056 |
439 | 2.571482 | 49.02379 | 77.28817 |
440 | 2.571224 | 49.02377 | 74.53242 |
441 | 2.570957 | 49.02375 | 71.67234 |
442 | 2.570682 | 49.02373 | 68.70683 |
443 | 2.570401 | 49.02373 | 65.63538 |
444 | 2.570116 | 49.02372 | 62.45895 |
445 | 2.569827 | 49.02372 | 59.18078 |
446 | 2.569537 | 49.02372 | 55.80708 |
447 | 2.569246 | 49.02371 | 52.34767 |
448 | 2.568955 | 49.02371 | 48.81642 |
449 | 2.568666 | 49.0237 | 45.23147 |
450 | 2.568379 | 49.02369 | 41.61519 |
451 | 2.568095 | 49.02367 | 37.99392 |
452 | 2.567814 | 49.02365 | 34.39742 |
453 | 2.567538 | 49.02364 | 30.85811 |
454 | 2.567266 | 49.02361 | 27.41008 |
455 | 2.566999 | 49.02359 | 24.08795 |
456 | 2.566737 | 49.02357 | 20.92557 |
457 | 2.56648 | 49.02355 | 17.95478 |
458 | 2.566228 | 49.02352 | 15.20407 |
459 | 2.565981 | 49.0235 | 12.69742 |
460 | 2.565739 | 49.02349 | 10.45322 |
461 | 2.565503 | 49.02347 | 8.483496 |
462 | 2.565272 | 49.02346 | 6.793307 |
463 | 2.565046 | 49.02345 | 5.380534 |
464 | 2.564827 | 49.02344 | 4.235935 |
465 | 2.564613 | 49.02344 | 3.343557 |
466 | 2.564405 | 49.02344 | 2.681455 |
467 | 2.564204 | 49.02343 | 2.22271 |
468 | 2.564009 | 49.02343 | 1.936681 |
469 | 2.563822 | 49.02343 | 1.790431 |
470 | 2.563642 | 49.02343 | 1.75028 |
471 | 2.56347 | 49.02343 | 1.783363 |
472 | 2.563306 | 49.02342 | 1.859156 |
473 | 2.563151 | 49.02341 | 1.950854 |
474 | 2.563004 | 49.0234 | 2.036537 |
475 | 2.562867 | 49.02339 | 2.100067 |
476 | 2.562738 | 49.02338 | 2.131643 |
477 | 2.562618 | 49.02336 | 2.127998 |
478 | 2.562507 | 49.02334 | 2.092205 |
479 | 2.562405 | 49.02332 | 2.03311 |
480 | 2.562311 | 49.0233 | 1.964406 |
481 | 2.562226 | 49.02328 | 1.903398 |
482 | 2.562148 | 49.02326 | 1.869526 |
483 | 2.562077 | 49.02324 | 1.882721 |
484 | 2.562012 | 49.02322 | 1.961688 |
485 | 2.561954 | 49.0232 | 2.122211 |
486 | 2.561902 | 49.02319 | 2.375588 |
487 | 2.561854 | 49.02318 | 2.727292 |
488 | 2.561811 | 49.02317 | 3.175941 |
489 | 2.561773 | 49.02316 | 3.712667 |
490 | 2.561737 | 49.02316 | 4.320932 |
491 | 2.561706 | 49.02316 | 4.976838 |
492 | 2.561677 | 49.02316 | 5.649931 |
493 | 2.561651 | 49.02317 | 6.304511 |
494 | 2.561627 | 49.02317 | 6.901382 |
495 | 2.561604 | 49.02318 | 7.400002 |
496 | 2.561584 | 49.02318 | 7.760931 |
497 | 2.561565 | 49.02319 | 7.948487 |
498 | 2.561546 | 49.02319 | 7.933473 |
499 | 2.561527 | 49.0232 | 7.695859 |
500 | 2.561508 | 49.0232 | 7.227279 |
501 | 2.561487 | 49.0232 | 6.533209 |
502 | 2.561464 | 49.0232 | 5.634715 |
503 | 2.561437 | 49.0232 | 4.569646 |
504 | 2.561405 | 49.0232 | 3.3932 |
505 | 2.561366 | 49.02319 | 2.177796 |
506 | 2.56132 | 49.02319 | 1.012213 |
経度,緯度,高度が10進法で記録されている
≫度分秒と十進度の相互換算
↓ソースコードはここ
↓公式ドキュメントはこれ
(飛行経路の描画)
(フライト映像の作成)
それではいってみよう
simplekmlのインポート
simplekml
をインポートする
PS C:\Users\mtkbirdman\Desktop\igc> pip install simplekml
Collecting simplekml
Downloading https://files.pythonhosted.org/packages/15/e4/c333a93b7e3346437ad1ff42b8e362b853eb405ad6243ab6163f9af2a460/simplekml-1.3.6.tar.gz (52kB)
100% |████████████████████████████████| 61kB 5.1MB/s
Installing collected packages: simplekml
Running setup.py install for simplekml ... done
Successfully installed simplekml-1.3.6
pipを使えば特に問題なく実行できる
ソースコード
ソースコード全文はこれ
≫https://github.com/mtkbirdman/mtkbirdman.com/blob/master/igc/IGCfileToGoogleEarthTour.py
import os
import numpy as np
import pandas as pd
import simplekml
# Import CSV file from current directory
path = '2023-02-22-XNA-9AD179D6D6F04DDD95474658245E6D4F-01'+'.csv'
df_B = pd.read_csv(os.path.join(os.getcwd(),path),header=0,index_col=0)
# Convert dataframe to list of tuple
tuple_B = [tuple(x) for x in df_B[['longitude','latitude','press_alt']].values]
# Convert longitude/latitude to the distance from the point of beginning
dt = 1
lat = np.radians(df_B.latitude.values-df_B.latitude.values[0])*6378137
lng = np.radians(df_B.longitude.values-df_B.longitude.values[0])*6378137
alt = df_B.press_alt.values
# Calculate the angles of yaw (heading), pitch (tilt) and roll from the coordinate
df_B['heading'] = 90
df_B['tilt'] = 90
df_B['roll'] = 0
for n in np.arange(len(df_B)):
if dt-1 < n and n < len(df_B)-dt:
a = lat[n+dt]-lat[n-dt]
b = lng[n+dt]-lng[n-dt]
c = lng[n-dt]*lat[n+dt]-lng[n+dt]*lat[n-dt]
d = np.sqrt(a*a+b*b)
e = np.abs(-a*lng[n]+b*lat[n]+c)/d
# Calculate turn radius and rate
R = (d*d+4*e*e)/(8*e)
Omega = np.arcsin((d/2)/R)/dt
# Calculate yaw, pitch and roll
df_B.loc[n,'heading'] = -np.rad2deg(np.arctan2(a,b))-(-90)
df_B.loc[n,'tilt'] = 90+np.rad2deg(np.arctan2(alt[n+dt]-alt[n-dt],d))
df_B.loc[n,'roll'] = np.rad2deg(np.arctan2(R*Omega*Omega,9.81))
# Modification
df_B.loc[n,'heading'] = df_B.heading[n]-360 if df_B.heading[n] > 180 else df_B.heading[n]
df_B.loc[n,'roll'] = -df_B.roll[n] if -a*lng[n]+b*lat[n]+c < 0 else df_B.roll[n]
# Insert values to beginning and end of dataframe
df_B.loc[0:dt,'heading'] = df_B.heading[dt]
df_B.loc[0:dt,'tilt'] = df_B.tilt[dt]
df_B.loc[len(df_B)-dt:,'heading'] = df_B.heading[len(df_B)-dt-1]
df_B.loc[len(df_B)-dt:,'tilt'] = df_B.tilt[len(df_B)-dt-1]
## Create an instance of Kml
kml = simplekml.Kml(open=1)
# Create a linestring
linestring = kml.newlinestring(name="A Sloped Line")
linestring.coords = tuple_B
linestring.altitudemode = simplekml.AltitudeMode.relativetoground
linestring.extrude = 0
linestring.style.linestyle.width = 3
linestring.style.linestyle.color = simplekml.Color.red
# Create a tour and attach a playlist to it
tour = kml.newgxtour(name="Take-Off!")
playlist = tour.newgxplaylist()
n=0
for _ in df_B.iterrows():
# Attach a gx:FlyTo to the playlist
flyto = playlist.newgxflyto()
flyto.camera.longitude = df_B.longitude[n]
flyto.camera.latitude = df_B.latitude[n]
flyto.camera.altitude = df_B.press_alt[n]+1.
flyto.camera.heading = df_B.heading[n]
flyto.camera.tilt = df_B.tilt[n]
flyto.camera.roll = df_B.roll[n]
flyto.gxduration = 1.
flyto.gxflytomode = 'smooth'
n+=1
# Attach a gx:Wait to the playlist to give the gx:AnimatedUpdate time to finish
wait = playlist.newgxwait(gxduration=3)
# Save to file
kml.save(os.path.join(os.getcwd(),path[:-4]+".kml"))
ひとつずつ解説していく
# Import CSV file from current directory
# Import CSV file from current directory
path = '2023-02-22-XNA-9AD179D6D6F04DDD95474658245E6D4F-01'+'.csv'
df_B = pd.read_csv(os.path.join(os.getcwd(),'csv',path),header=0,index_col=0)
# Convert dataframe to list of tuple
tuple_B = [tuple(x) for x in df_B[['longitude','latitude','press_alt']].values]
CSVファイルをpd.read_csv()
でデータフレームdf_B
として読み込み,リスト内法表記を使ってタプルのリストtuple_B
に変換している
タプルのリストはGoogle Earthに飛行軌跡をプロットするのに必要になる
≫pandas.read_csv — pandas 1.5.3 documentation
# Convert longitude/latitude to the distance from the point of beginning
# Convert longitude/latitude to the distance from the point of beginning
dt = 1
lat = np.radians(df_B.latitude.values-df_B.latitude.values[0])*6378137
lng = np.radians(df_B.longitude.values-df_B.longitude.values[0])*6378137
alt = df_B.press_alt.values
後ほどオイラー角(ヨー/ピッチ/ロール)の計算に使用するため,度数表記の緯度経度をフライトの始点からの距離[m]に変換する
簡単のため地球を完全な球体だとし,地球の半径6,378,237mと三角関数の微小近似を使って計算している
# Calculate the angles of yaw (heading), pitch (tilt) and roll from the coordinate
# Calculate the angles of yaw (heading), pitch (tilt) and roll from the coordinate
df_B['heading'] = 90
df_B['tilt'] = 90
df_B['roll'] = 0
for n in np.arange(len(df_B)):
if dt-1 < n and n < len(df_B)-dt:
a = lat[n+dt]-lat[n-dt]
b = lng[n+dt]-lng[n-dt]
c = lng[n-dt]*lat[n+dt]-lng[n+dt]*lat[n-dt]
d = np.sqrt(a*a+b*b)
e = np.abs(-a*lng[n]+b*lat[n]+c)/d
# Calculate turn radius and rate
R = (d*d+4*e*e)/(8*e)
Omega = np.arcsin((d/2)/R)/dt
# Calculate yaw, pitch and roll
df_B.loc[n,'heading'] = -np.rad2deg(np.arctan2(a,b))-(-90)
df_B.loc[n,'tilt'] = 90+np.rad2deg(np.arctan2(alt[n+dt]-alt[n-dt],d))
df_B.loc[n,'roll'] = np.rad2deg(np.arctan2(R*Omega*Omega,9.81))
# Modification
df_B.loc[n,'heading'] = df_B.heading[n]-360 if df_B.heading[n] > 180 else df_B.heading[n]
df_B.loc[n,'roll'] = -df_B.roll[n] if -a*lng[n]+b*lat[n]+c < 0 else df_B.roll[n]
フライト映像をそれっぽく見せるため,フライトログからオイラー角(ヨー/ピッチ/ロール)を計算し,それに応じて画面を傾けて表示する
具体的な計算を行うために,座標系を以下のように定義する
ここで,下図の各値は以下のように計算できる
\begin{align}
&a=y_{n+1}-y_{n-1} \\\\
&b=x_{n+1}-x_{n-1} \\\\
&c=x_{n-1}y_{n+1}-x_{n+1}y_{n-1}\\\\
&d=\sqrt{\left(x_{n+1}-x_{n-1}\right)^{2}+\left(y_{n+1}-y_{n-1}\right)^{2}}=\sqrt{a^2+b^2}\\\\
&e=\frac{\left|-ax_{n}+by_{n}+c\right|}{\sqrt{a^{2}+b^{2}}}=\frac{\left|-ax_{n}+by_{n}+c\right|}{d} \\\\
&R=\frac{d^{2}+4e^{2}}{8e} \\\\
&\theta=\arcsin{\left(\frac{d/2}{R}\right)}\simeq \frac{d}{2R} \\\\
&\Omega=\frac{\theta}{\Delta t}
\end{align}
XY平面上において,2点(\(x_{n+1}, y_{n+1}\)),(\(x_{n-1}, y_{n-1}\))を通る直線の式は以下の式で表される
\begin{align}
&y-y_{n-1}=\frac{y_{n+1}-y_{n-1}}{x_{n+1}-x_{n-1}}\left(x-x_{n-1}\right) \\
\rightarrow & -\left(y_{n+1}-y_{n-1}\right)x+\left(x_{n+1}-x_{n-1}\right)y+\left(x_{n-1}y_{n+1}-x_{n+1}y_{n-1}\right)=0 \\
\rightarrow & -ax+by+c=0 \\\\
&\left\{\begin{array}{l}
a=y_{n+1}-y_{n-1} \\
b=x_{n+1}-x_{n-1} \\
c=x_{n-1}y_{n+1}-x_{n+1}y_{n-1}\\
\end{array}\right.
\end{align}
この直線と点(\(x_{n}, y_{n}\))の距離は,点と直線の距離の公式より以下のようになる
\begin{align}
e=\frac{\left|-ax_{n}+by_{n}+c\right|}{\sqrt{a^{2}+b^{2}}}=\frac{\left|-ax_{n}+by_{n}+c\right|}{d}
\end{align}
また,扇形の図に着目すると以下の関係が分かる
\begin{align}
&\left\{\begin{array}{l}
R\sin{\theta}=d/2 \\
R(1-\cos{\theta})=e \\
\end{array}\right.
\rightarrow \left\{\begin{array}{l}
\sin{\theta}=\frac{d/2}{R} \\
\cos{\theta}=1-\frac{e}{R} \\
\end{array}\right.
\end{align}
\(\sin{\theta}^2+\cos{\theta}^2=1\)より
\begin{align}
&\left(\frac{d/2}{R}\right)^2+\left(1-\frac{e}{R}\right)^2=1
\rightarrow R=\frac{d^2+4e^2}{8e}
\end{align}
このようにして計算した\(a,\cdots,e, R,\Omega\)を用いるとオイラー角(ヨー/ピッチ/ロール)[deg] は以下のように計算できる
\begin{align}
&\psi=\frac{180}{\pi}\arctan{\left(\frac{a}{b}\right)}-(-90) \\\\
&\theta=90+\frac{180}{\pi}\arctan{\left(\frac{z_{n+1}-z_{n-1}}{d}\right)} \\\\
&\phi=\frac{180}{\pi}\arctan{\left(\frac{R\Omega^2}{g}\right)} \\\\
\end{align}
バンク角\(\phi\)で旋回しているとき,上下の力のつり合いおよび円運動の方程式は以下のようになる
\begin{align}
&\left\{\begin{array}{l}
&L\cos{\phi}=Mg \\
&L\sin{\phi}=MR\Omega^2
\end{array}\right.
\end{align}
上式から\(L\)を消去すると次の式が得られる
\begin{align}
&\tan{\phi}=\frac{R\Omega^2}{g} \\\\
&\rightarrow \phi=\frac{180}{\pi}\arctan{\left(\frac{R\Omega^2}{g}\right)}
\end{align}
以上の計算を行ったうえでデータの一番最初と最後に値を補完する
# Insert values to beginning and end of dataframe
df_B.loc[0:dt,'heading'] = df_B.heading[dt]
df_B.loc[0:dt,'tilt'] = df_B.tilt[dt]
df_B.loc[len(df_B)-dt:,'heading'] = df_B.heading[len(df_B)-dt-1]
df_B.loc[len(df_B)-dt:,'tilt'] = df_B.tilt[len(df_B)-dt-1]
# Create a linestring
## Create an instance of Kml
kml = simplekml.Kml(open=1)
# Create a linestring
linestring = kml.newlinestring(name="A Sloped Line")
linestring.coords = tuple_B
linestring.altitudemode = simplekml.AltitudeMode.relativetoground
linestring.extrude = 0
linestring.style.linestyle.width = 3
linestring.style.linestyle.color = simplekml.Color.red
kmlのインスタンスを作成し,kml.newlinestring()
を使って飛行軌跡をプロットする
simplekml.LineString
の設定は以下の通り
オプション | 説明 | 例 |
coords | 座標を表すタプルのリスト(経度,緯度,高度) | tuple_B |
altitudemode | 標高モード | simplekml.AltitudeMode.relativetoground |
extrude | 地表面からの押出し(0/1) | 0 |
style.linestyle.width | 線の太さ | 3 |
style.linestyle.color | 線の色 | simplekml.Color.red |
↓参考のドキュメント
# Create a tour and attach a playlist to it
# Create a tour and attach a playlist to it
tour = kml.newgxtour(name="Take-Off!")
playlist = tour.newgxplaylist()
n=0
for _ in df_B.iterrows():
# Attach a gx:FlyTo to the playlist
flyto = playlist.newgxflyto()
flyto.camera.longitude = df_B.longitude[n]
flyto.camera.latitude = df_B.latitude[n]
flyto.camera.altitude = df_B.press_alt[n]+1.
flyto.camera.heading = df_B.heading[n]
flyto.camera.tilt = df_B.tilt[n]
flyto.camera.roll = df_B.roll[n]
flyto.gxduration = 1.
flyto.gxflytomode = 'smooth'
n+=1
kml.newgxtour()
でツアーを作成し,tour.newgxplaylist()
でツアーの中にプレイリストを作成する
playlist.newgxflyto()
で作成したプレイリストの中に目的地を追加していく
オプションは以下の通り
オプション | 説明 | 単位 | 例 |
flyto.camera.longitude | 緯度 | deg | df_B.longitude[n] |
flyto.camera.latitude | 経度 | deg | df_B.latitude[n] |
flyto.camera.altitude | 高度 | m | df_B.press_alt[n]+1. |
flyto.camera.heading | ヨー角 | deg | df_B.heading[n] |
flyto.camera.tilt | ピッチ角 | deg | df_B.tilt[n] |
flyto.camera.roll | ロール角 | deg | df_B.roll[n] |
flyto.gxduration | フレーム間隔 | s | 1 |
flyto.gxflytomode | カメラの移動方法 | - | 'smooth' |
flyto.gxduration
はフレームごとに時間間隔である
今回はGPSのデータ取得間隔に合わせて1.0 [s] としたが,ここをいじることで再生速度を変更することができる
カメラをぬるぬる動かすためにはflyto.gxflytomode
で'smooth'
を指定する
↓参考
# Save to file
# Attach a gx:Wait to the playlist to give the gx:AnimatedUpdate time to finish
wait = playlist.newgxwait(gxduration=3)
# Save to file
kml.save(os.path.join(os.getcwd(),path[:-4]+".kml"))
フライト後の余韻の時間を設定し,kmlファイルを保存する
以上でプログラムの解説は終了である
実行結果
VS codeなりubuntuなりにPythonの実行環境を構築して、以下のコマンドでプログラムを実行する
$: py -3.6 IGCfileToCSV.py
$: py -3.6 IGCfileToGoogleEarthTour.py
.kmlファイルが出力される
/mnt/c/Users/mtkbirdman/Desktop/igc
├── 2023-02-22-XNA-9AD179D6D6F04DDD95474658245E6D4F-01.csv
├── 2023-02-22-XNA-9AD179D6D6F04DDD95474658245E6D4F-01.igc
├── 2023-02-22-XNA-9AD179D6D6F04DDD95474658245E6D4F-01.kml
├── 2023-02-22-XNA-9AD179D6D6F04DDD95474658245E6D4F-01FFT.igc
├── IGCfileToCSV.py
└── IGCfileToGoogleEarthTour.py
IGCfileToCSV.py
はフライトログに一般的に用いられる.igcファイルからGoogleEarth用のCSVファイルを作成するプログラムである
≫https://github.com/mtkbirdman/mtkbirdman.com/blob/master/igc/IGCfileToCSV.py
↓参考
GoogleEarthにkmlファイルをインポートする
Google Earthを開き,左側のメニューから「Projects」を選択する
メニュー上部から「New Project>Import KML file from computer」を選択する
.kmlファイルを選択して開く
読み込んだ.kmlファイルの場所までびよーんと飛んでいく
「Take Off!」をクリックするとフライト動画が再生される
あとは煮るなり焼くなり好きにすればいい
↓Windows10/11の標準機能で画面録画する方法
おわりに
GPSフライトログのCSVファイルをもとに、simplekmlを使ってGoogleEarthで飛行機のパイロット目線の映像を作るPythonプログラムについて説明した
↓関連記事
コメント