Get the App
SLTechnology News&Howtos  ›  Development  › 

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

Shulou Source: shulou.com Published: 2022-06-02 22:17:49 10月02日 Update

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!

Tags: Subway first line dynamic city production operation data route route map learning more perspective Beijing help practical next central point north its into graphics Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft MySQL Shulou Information MariaDB