Python获取航线信息并且制作成图的讲解

 更新时间:2019年01月03日 10:46:22   作者:staHuri   我要评论
今天小编就为大家分享一篇关于Python获取航线信息并且制作成图的讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧

获取航线信息并且制作成图

航线信息

写入本地文件

import requests
import json
url =""
html = requests.get(url)
with open('CES5496.json','w') as f:
  json.dump(html.text,f)

解析json文件

  • 把json文件中的相关坐标信息 提取到一个list中以便使用
import json
with open('CES5496.json', encoding='utf-8') as data_file:
  data = json.loads(data_file.read().replace('true','True').replace('null','None').replace('false','False'))
jdata = dict(eval(data))
xy = jdata['flights']['CES5496-1530336340-airline-0406:0']['track']
coordList = list()
for index in range(xy.__len__()):
  # print(xy[index])
  coordList.append(xy[index]['coord'][::-1])
print(coordList)

绘制图形

  • 使用的库为folium
  • 使用folium.PolyLine 绘制线
  • 使用plugins.PolyLineTextPath 绘制飞机
from folium import plugins
import folium
m = folium.Map([30.1833, 120.2833], zoom_start=5)
zuobiao = [[30.2308, 120.437], [30.2341, 120.4454], [30.2369, 120.4548], [30.2394, 120.465], [30.2447, 120.491],
      [30.2501, 120.519], [30.256, 120.551], [30.2572, 120.5673], [30.2566, 120.5803], [30.2541, 120.59],
      [30.2486, 120.5986], [30.2387, 120.6082], [30.2244, 120.619], [30.2133, 120.6255], [30.2041, 120.6303],
      [30.1966, 120.6335], [30.19, 120.6351], [30.1829, 120.6353], [30.1754, 120.634], [30.1682, 120.6315],
      [30.1619, 120.628], [30.1566, 120.6235], [30.1491, 120.612], [30.1366, 120.5875], [30.1189, 120.55],
      [30.1024, 120.513], [30.0784, 120.458], [30.054, 120.403], [30.0298, 120.349], [29.9804, 120.24],
      [29.9548, 120.187], [29.9185, 120.111], [29.889, 120.049], [29.8663, 119.991], [29.8375, 119.904],
      [29.8167, 119.841], [29.7959, 119.778], [29.776, 119.718], [29.7561, 119.658], [29.7362, 119.598],
      [29.7166, 119.539], [29.679, 119.426], [29.636, 119.297], [29.5898, 119.167], [29.5672, 119.103],
      [29.5573, 119.0669], [29.5489, 119.0212], [29.5421, 118.966], [29.5402, 118.934], [29.5374, 118.9047],
      [29.5335, 118.878], [29.5273, 118.8494], [29.5179, 118.8144], [29.5051, 118.773], [29.4848, 118.717],
      [29.4483, 118.6148], [29.3752, 118.4101], [29.3492, 118.3379], [29.3005, 118.2022], [29.2334, 118.0149],
      [29.1642, 117.8207], [28.9964, 117.352], [28.9489, 117.2185], [28.9244, 117.1499], [28.9001, 117.0818],
      [28.8768, 117.0164], [28.8514, 116.9458], [28.8071, 116.8224], [28.782, 116.7529], [28.7578, 116.6858],
      [28.7331, 116.617], [28.7091, 116.5493], [28.6849, 116.4812], [28.661, 116.4146], [28.6364, 116.346],
      [28.6122, 116.2783], [28.5883, 116.212], [28.5639, 116.1443], [28.5392, 116.076], [28.5148, 116.0083],
      [28.5003, 115.9631], [28.4889, 115.9242], [28.4808, 115.8914], [28.4742, 115.8579], [28.4673, 115.8167],
      [28.4603, 115.7678], [28.4506, 115.6949], [28.4409, 115.6221], [28.431, 115.5478], [28.4121, 115.4086],
      [28.3859, 115.2279], [28.3718, 115.1332], [28.3584, 115.0436], [28.3261, 114.8117], [28.316, 114.7369],
      [28.3058, 114.6629], [28.2964, 114.5945], [28.2821, 114.4904], [28.2662, 114.3765], [28.2562, 114.3036],
      [28.2466, 114.2295], [28.2339, 114.1332], [28.2239, 114.0587], [28.2124, 113.9735], [28.1859, 113.7782],
      [28.176, 113.7054], [28.1558, 113.5572], [28.14, 113.4356], [28.1137, 113.2528], [28.1021, 113.1776],
      [28.0908, 113.1034], [28.0795, 113.0276], [28.0763, 112.9783], [28.0747, 112.9282], [28.0747, 112.8771],
      [28.0848, 112.727], [28.0956, 112.5666], [28.0931, 112.4948], [28.0865, 112.4376], [28.0756, 112.3948],
      [28.0629, 112.3577], [28.0505, 112.3173], [28.0385, 112.2735], [28.0308, 112.2272], [28.0313, 112.1792],
      [28.04, 112.1294], [28.0547, 112.0802], [28.073, 112.0343], [28.095, 111.9914], [28.1307, 111.9292],
      [28.1749, 111.8392], [28.214, 111.7575], [28.2436, 111.6953], [28.2759, 111.6273], [28.3073, 111.5614],
      [28.3381, 111.4967], [28.3679, 111.4335], [28.3999, 111.3655], [28.4312, 111.2994], [28.4628, 111.2326],
      [28.4932, 111.1683], [28.5242, 111.1022], [28.5608, 111.021], [28.5881, 110.9536], [28.6064, 110.8999],
      [28.6173, 110.8558], [28.6229, 110.8169], [28.6232, 110.7833], [28.6195, 110.7496], [28.613, 110.7105],
      [28.6037, 110.6659], [28.5874, 110.5919], [28.5802, 110.5494], [28.576, 110.5175], [28.5748, 110.4963],
      [28.5758, 110.4803], [28.5779, 110.4641], [28.5811, 110.4477], [28.5853, 110.4317], [28.5904, 110.4166],
      [28.5963, 110.4023], [28.6031, 110.3887], [28.6109, 110.3756], [28.6195, 110.3628], [28.6338, 110.3452],
      [28.6586, 110.3177], [28.6939, 110.28], [28.7403, 110.2318], [28.7748, 110.1959], [28.8817, 110.0845],
      [28.9942, 109.9667], [29.0422, 109.9164], [29.0835, 109.8729], [29.1402, 109.8129], [29.1876, 109.7628],
      [29.2359, 109.7124], [29.2843, 109.6624], [29.3428, 109.6022], [29.3739, 109.5653], [29.4037, 109.5279],
      [29.4321, 109.49], [29.4789, 109.4256], [29.519, 109.37], [29.5935, 109.2664], [29.6324, 109.2121],
      [29.6728, 109.1558], [29.7097, 109.1043], [29.7509, 109.0468], [29.7907, 108.9912], [29.83, 108.936],
      [29.9072, 108.8277], [29.9557, 108.7489], [29.9867, 108.6944], [30.0002, 108.6642], [30.0044, 108.6458],
      [30.0073, 108.6264], [30.0089, 108.6062], [30.0094, 108.5864], [30.0089, 108.5682], [30.0072, 108.5518],
      [30.0026, 108.5279], [29.993, 108.4878], [29.9786, 108.4313], [29.9618, 108.3672], [29.9426, 108.2942],
      [29.9246, 108.2262], [29.9066, 108.1581], [29.8816, 108.0642], [29.8495, 107.9438], [29.8323, 107.8796],
      [29.8157, 107.8173], [29.777, 107.6732], [29.7489, 107.5644], [29.7384, 107.5208], [29.7316, 107.4885],
      [29.7283, 107.4675], [29.7279, 107.4507], [29.7293, 107.4313], [29.7325, 107.4091], [29.7371, 107.3872],
      [29.7425, 107.3685], [29.7488, 107.3531], [29.7572, 107.3387], [29.769, 107.3232], [29.7842, 107.3064],
      [29.8099, 107.2835], [29.8534, 107.2495], [29.9148, 107.2045], [29.9453, 107.1827], [29.9678, 107.1674],
      [29.9821, 107.1585], [29.9951, 107.154], [30.0138, 107.1521], [30.0381, 107.1527], [30.0618, 107.1551],
      [30.0786, 107.1585], [30.0883, 107.163], [30.0948, 107.1691], [30.1015, 107.1773], [30.1085, 107.1875],
      [30.1149, 107.2001], [30.1196, 107.2154], [30.1228, 107.2332], [30.1238, 107.2518], [30.1223, 107.269],
      [30.1182, 107.2848], [30.1117, 107.2993], [30.1029, 107.3125], [30.0917, 107.3244], [30.0796, 107.3342],
      [30.0681, 107.341], [30.057, 107.345], [30.0451, 107.3459], [30.0307, 107.3437], [30.014, 107.3384],
      [29.9974, 107.3298], [29.9833, 107.3177], [29.9718, 107.3022], [29.9633, 107.2847], [29.9584, 107.2666],
      [29.957, 107.248], [29.9609, 107.2285], [29.972, 107.2079], [29.9902, 107.186], [30.0107, 107.1674],
      [30.0284, 107.1563], [30.0434, 107.1527], [30.0568, 107.1541], [30.0698, 107.1579], [30.0824, 107.1639],
      [30.0941, 107.1722], [30.1046, 107.1825], [30.1137, 107.1948], [30.1211, 107.2088], [30.1262, 107.2242],
      [30.1292, 107.241], [30.1301, 107.2575], [30.1292, 107.2722], [30.1264, 107.2852], [30.1221, 107.2968],
      [30.1166, 107.3072], [30.1101, 107.3166], [30.101, 107.3249], [30.088, 107.332], [30.071, 107.338],
      [30.0535, 107.3417], [30.0387, 107.342], [30.0267, 107.339], [30.0164, 107.3335], [30.0072, 107.3263],
      [29.9988, 107.3174], [29.9918, 107.3079], [29.9865, 107.2987], [29.9829, 107.2899], [29.9808, 107.2798],
      [29.98, 107.2665], [29.9806, 107.2502], [29.9828, 107.2331], [29.9868, 107.2176], [29.9928, 107.2036],
      [30.0003, 107.191], [30.0089, 107.1794], [30.0188, 107.169], [30.0336, 107.1563], [30.0571, 107.138],
      [30.0894, 107.114], [30.3443, 106.9295], [30.3979, 106.8912], [30.4521, 106.8525], [30.504, 106.816],
      [30.5633, 106.7748], [30.6399, 106.7207], [30.6689, 106.7001], [30.6926, 106.6843], [30.7108, 106.6732],
      [30.726, 106.6655], [30.7403, 106.6597], [30.7539, 106.6559], [30.7673, 106.6538], [30.7808, 106.653],
      [30.7947, 106.6535], [30.8083, 106.6554], [30.8215, 106.6588], [30.8342, 106.6635], [30.8462, 106.6697],
      [30.8575, 106.6775], [30.8679, 106.6867], [30.8773, 106.6971], [30.8851, 106.7085], [30.8915, 106.7207],
      [30.8963, 106.7336], [30.8995, 106.7468], [30.9011, 106.7604], [30.901, 106.7741], [30.8992, 106.7874],
      [30.8958, 106.8005], [30.8908, 106.8129], [30.8841, 106.8243], [30.8759, 106.8348], [30.8665, 106.8438],
      [30.8563, 106.8509], [30.8454, 106.8562], [30.834, 106.8596], [30.8226, 106.861], [30.8111, 106.8605],
      [30.799, 106.8574], [30.786, 106.8508], [30.7721, 106.8408], [30.7593, 106.8238], [30.7497, 106.7964],
      [30.7433, 106.7584], [30.741, 106.7181], [30.7437, 106.6835], [30.7514, 106.6547], [30.7837, 106.5844],
      [30.816, 106.5143], [30.8461, 106.4494], [30.9088, 106.3144], [30.938, 106.2513], [31.1099, 105.8875],
      [31.14, 105.823], [31.1662, 105.7756], [31.2011, 105.7273], [31.2448, 105.6783], [31.2773, 105.62],
      [31.2783, 105.544], [31.2481, 105.4503], [31.2079, 105.3538], [31.1791, 105.2696], [31.1618, 105.1976],
      [31.1508, 105.1401], [31.1411, 105.0992], [31.1326, 105.0749], [31.1192, 105.0512], [31.0948, 105.0119],
      [31.0594, 104.9571], [31.0304, 104.9171], [31.0135, 104.8938], [31.0012, 104.8759], [30.9934, 104.8634],
      [30.9868, 104.8502], [30.9778, 104.8303], [30.9664, 104.8039], [30.9318, 104.7216], [30.916, 104.6838],
      [30.8941, 104.6316], [30.8822, 104.6031], [30.8562, 104.5416], [30.845, 104.5155], [30.8399, 104.4992],
      [30.8372, 104.4854], [30.8368, 104.4742], [30.8388, 104.4605], [30.8434, 104.4394], [30.8506, 104.4109],
      [30.8552, 104.3933], [30.8614, 104.3701], [30.8697, 104.3393], [30.8822, 104.2929], [30.8899, 104.2649],
      [30.8964, 104.2408], [30.9005, 104.2218], [30.9025, 104.2065], [30.9023, 104.195], [30.9002, 104.1838],
      [30.8963, 104.1698], [30.8906, 104.1527], [30.8814, 104.1274], [30.8735, 104.1055], [30.8585, 104.064],
      [30.8502, 104.0411], [30.8402, 104.0137], [30.8333, 103.9946], [30.8219, 103.9636], [30.8053, 103.9189],
      [30.7972, 103.9012], [30.7895, 103.8878], [30.7821, 103.8788], [30.7724, 103.8721], [30.7575, 103.8659],
      [30.7375, 103.86], [30.7125, 103.8557], [30.6763, 103.8492], [30.6653, 103.8469], [30.6547, 103.8442],
      [30.6448, 103.8411], [30.6351, 103.8375], [30.6253, 103.8334], [30.6155, 103.8286], [30.5866, 103.8142],
      [30.558, 103.8002], [30.52, 103.7817], [30.4939, 103.7693], [30.4766, 103.761], [30.4623, 103.7541],
      [30.4466, 103.7466], [30.4313, 103.7393], [30.4163, 103.732], [30.3744, 103.7118], [30.3595, 103.7046],
      [30.3329, 103.6917], [30.3061, 103.6785], [30.292, 103.6715], [30.277, 103.6641], [30.2657, 103.6588],
      [30.258, 103.6556], [30.2523, 103.6543], [30.2469, 103.6544], [30.2418, 103.6561], [30.2374, 103.6589],
      [30.2342, 103.6624], [30.232, 103.6667], [30.231, 103.6718], [30.2312, 103.678], [30.2325, 103.6852],
      [30.2344, 103.6924], [30.2364, 103.6987], [30.2384, 103.7041], [30.2418, 103.7104], [30.248, 103.7197],
      [30.2569, 103.7319], [30.2647, 103.7424], [30.2792, 103.7627], [30.289, 103.7753], [30.2973, 103.7853],
      [30.3042, 103.7927], [30.3169, 103.8051], [30.339, 103.8266], [30.3457, 103.8328], [30.3523, 103.8382],
      [30.3589, 103.8428], [30.3723, 103.8501], [30.3993, 103.8634], [30.44, 103.8827], [30.4504, 103.8875],
      [30.4784, 103.9006], [30.4867, 103.9043], [30.4973, 103.9092], [30.5072, 103.9139], [30.5192, 103.9194],
      [30.5366, 103.9275], [30.5475, 103.9325], [30.5475, 103.9325], [30.5785, 103.9471]]
route = folium.PolyLine(
  zuobiao,
  weight=10,
  color='orange',
  opacity=0.8
).add_to(m)
# 警告图例
attr = {'fill': 'red'}
# 飞机图例
aircraft = {'font-weight': 'bold', 'font-size': '24'}
plugins.PolyLineTextPath(
  route,
  # '\u25BA', # 图例样式
  '\u2708',
  repeat=True,
  offset=0,
  attributes=aircraft
).add_to(m)
m.save("feiji.html")

成果展示

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对澳门金沙网上娱乐的支持。如果你想了解更多相关内容请查看下面相关链接

相关文章

  • 关于反爬虫的一些简单总结

    关于反爬虫的一些简单总结

    这篇文章主要介绍了关于反爬虫的一些简单总结,具有一定借鉴价值,需要的朋友可以参考下。
    2017-12-12
  • 用Python中的wxPython实现最基本的浏览器功能

    用Python中的wxPython实现最基本的浏览器功能

    这篇文章主要介绍了用Python中的wxPython实现基本的浏览器功能,本文来自于IBM官方网站开发者文档,需要的朋友可以参考下
    2015-04-04
  • Django forms表单 select下拉框的传值实例

    Django forms表单 select下拉框的传值实例

    今天小编就为大家分享一篇Django forms表单 select下拉框的传值实例。具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-07-07
  • python日期相关操作实例小结

    python日期相关操作实例小结

    这篇文章主要介绍了python日期相关操作,结合实例形式总结分析了Python针对日期时间的获取、转换、运算等相关操作技巧,需要的朋友可以参考下
    2019-06-06
  • Python 3 判断2个字典相同

    Python 3 判断2个字典相同

    这篇文章主要介绍了Python 3 判断2个字典相同,文中给大家提到了Python3 查找两字典的相同点问题及解决方法,需要的朋友可以参考下
    2019-08-08
  • Linux环境下MySQL-python安装过程分享

    Linux环境下MySQL-python安装过程分享

    这篇文章主要介绍了Linux环境下MySQL-python安装过程分享,本文使用的编译方式安装,需要的朋友可以参考下
    2015-02-02
  • 将python文件打包成EXE应用程序的方法

    将python文件打包成EXE应用程序的方法

    相信大家都想把自己完成的项目打包成EXE应用文件,然后就可以放在桌面随时都能运行了,下面来分享利用pytinstaller这个第三方库来打包程序,感兴趣的朋友跟随小编一起看看吧
    2019-05-05
  • Python 3.x 判断 dict 是否包含某键值的实例讲解

    Python 3.x 判断 dict 是否包含某键值的实例讲解

    今天小编就为大家分享一篇Python 3.x 判断 dict 是否包含某键值的实例讲解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-07-07
  • python制作爬虫爬取京东商品评论教程

    python制作爬虫爬取京东商品评论教程

    本文是继前2篇Python爬虫系列文章的后续篇,给大家介绍的是如何使用Python爬取京东商品评论信息的方法,并根据数据绘制成各种图表,非常的细致,有需要的小伙伴可以参考下
    2016-12-12
  • Python字典对象实现原理详解

    Python字典对象实现原理详解

    这篇文章主要介绍了Python字典对象实现原理详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-07-07

最新评论