Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use python to make dynamic Diagram of Metro Operation in first-tier cities

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to use python to make subway operation dynamic diagram of first-tier cities". In daily operation, I believe many people have doubts about how to use python to make subway operation dynamic diagram of first-tier cities. Xiaobian consulted all kinds of materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "how to use python to make subway operation dynamic diagram of first-tier cities"! Next, please follow the small series to learn together!

First, prepare the data. Take Beijing City as an example, grab the package on the subway page of Gaode Map

Beijing City subway information interface:

http://map.amap.com/service/subway?_ 1599997789354=&srhdata=1100_drw_beijing.json

Parse json data into Bmap data format

import requests import jsonurl='http://map.amap.com/service/subway?_ 1599997789354=&srhdata=1100_drw_beijing.json' response=requests.get(url)result=json.loads(response.text)stations=[]for i in result['l']: station=[] for j in i['st']: station.append([float(k) for k in j['sl'].split(',')]) stations.append(station) print(stations)

1. Beijing Metro Line Map

from pyecharts.charts import BMap from pyecharts import options as opts from pyecharts.globals import BMapType, ChartType c=( BMap(init_opts=opts.InitOpts(width="1600px", height="800px")) .add_schema( baidu_ak="", #baidu secret key ak center=[116.397128, 39.916527], #Center point of current viewing angle, expressed in latitude and longitude zoom=14, #Scale of current viewing angle is_roam=True, #Turn on mouse zoom and pan roaming ) .add( series_name="", type_=ChartType.LINES, data_pair=stations, is_polyline=True, #Is it a polyline is_large=True, #Whether to enable optimization of large-scale graphs, when there are a lot of data graphs (>= 5k) can be enabled linestyle_opts=opts.LineStyleOpts(color="purple", opacity=0.6, width=1), effect_opts=opts.EffectOpts(trail_length=0.5), ) .add_control_panel( copyright_control_opts=opts.BMapCopyrightTypeOpts(position=3), maptype_control_opts=opts.BMapTypeControlOpts( type_=BMapType.MAPTYPE_CONTROL_DROPDOWN ), scale_control_opts=opts.BMapScaleControlOpts(), overview_map_opts=opts.BMapOverviewMapControlOpts(is_open=True), navigation_control_opts=opts.BMapNavigationControlOpts(), geo_location_control_opts=opts.BMapGeoLocationControlOpts(), ))c.render_notebook()

2. Shanghai Metro Line Map

3. Guangzhou Metro Line Map

4. Shenzhen Metro Line Map

At this point, the study of "how to make a dynamic map of subway operation in first-tier cities with python" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report