python经纬度批量定位 绘制高清地图

import folium
import numpy as np
import pandas as pd
import webbrowser as wb
import mapa

result = input('请输入6位行政区码(如532901)?输入后回车')
bj_map = folium.Map(location=[25.600212,100.236162],zoom_start=10,no_touch=False)


df = pd.read_excel("单位经纬度信息.xlsx")
num=df.shape[0]
lat = np.array(df["纬度"][0:num])
# 获取经度
lon = np.array(df["经度"][0:num])
# 获取标记机构名称
mc = np.array(df["机构名称"][0:num])
# 获取办学类型作为判断
lxbm = np.array(df["机构类型编号"][0:num])
dz = np.array(df["机构地址"][0:num])

for i in range(num):
    if lxbm[i] == 111:
        bjs = "blue"
    elif lxbm[i] == 211:
        bjs = "red"
    elif lxbm[i] == 218:
        bjs = "darkred"
    elif lxbm[i] == 311:
        bjs = "green"
    elif lxbm[i] == 312:
        bjs = "lightgreen"
    elif lxbm[i] == 341:
        bjs = "gray"
    elif lxbm[i] == 342:
        bjs = "lightgray"
    elif lxbm[i] == 362:
        bjs = "orange"
    elif lxbm[i] > 362:
        bjs = "purple"
    if isinstance(lat[i],float):
        folium.Marker(
            location=[lat[i], lon[i]],
            popup=dz[i],
            # popup=folium.Popup(str(mc[i]),show=True),
            tooltip=mc[i],
            alt=mc[i],
            icon=folium.Icon(color=bjs, icon='info-sign')
        ).add_to(bj_map)

url = "https://geo.datav.aliyun.com/areas_v3/bound/"+str(result)+"_full.json"
print(url)
folium.GeoJson(
    url,
    name='geojson'
).add_to(bj_map)
mapa.run_map()
bj_map.save('map.html')
wb.open("map.html")

python经纬度批量定位 绘制高清地图

代码目录下的表格"单位经纬度信息.xlsx"包含信息:

python经纬度批量定位 绘制高清地图_第1张图片

 运行结果生成的地图为:(地图可以放大缩小)python经纬度批量定位 绘制高清地图_第2张图片

 

你可能感兴趣的:(python,numpy,开发语言)