这个是我生成的地图,里面路网都没有呢,shp文件我用得是我自己裁剪的一个北京的路网数据,里面没有路网是因为我裁剪的问题还是我代码的问题呢?
代码我参考了https://blog.csdn.net/qq_34862636/article/details/101602504#comments_12692153
下面是代码
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import pandas as pd
#-----底图绘制
matplotlib.rcParams['toolbar'] = 'None'
fig = plt.figure(figsize=(8, 8), edgecolor='w')
m = Basemap(projection='merc', #投影方式
llcrnrlon=116.55,#起始经度116
llcrnrlat=40.25, #起始纬度
urcrnrlon=116.80, #终止经度117
urcrnrlat=40.8,#终止纬度41
resolution='h',#设置边界的详细程度,h是高
)
island_col = '#FFDEAD' #陆地颜色
line_col = 'purple' #轨迹颜色
m.fillcontinents(color = island_col,lake_color = 'white')
m.drawparallels(np.arange(24,41,0.05),labels=[1,1,0,1])
m.drawmeridians(np.arange(112,120,0.05),labels=[1,1,0,1])
shp_info = m.readshapefile("wuhuan",'states',drawbounds=True)
#-----数据读取
posi = pd.read_csv('first_car.csv',header = 0, names = ['name','lng','lat'])
num = len(posi)
lng = posi["lng"].values # 获取经度值
lat = posi["lat"].values # 获取纬度值
x,y = m(lng,lat)
#-----轨迹绘制
#散点
m.scatter(x, y, s=1, c='r', alpha=0.7, zorder=10)
#连线
#m.plot(x,y,marker=None,color = line_col,linewidth = 1)
plt.show()