我试图在python 2.7中将彩色矢量绘制到地图上。 我可以毫无问题地绘制矢量和颜色,但是一旦我尝试添加海岸线就会出错。请帮忙
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from mpl_toolkits.basemap import Basemap
filename = 'wg_weather1_fixed.csv'
readcsv = pd.read_csv(filename)
temp = readcsv.Temperature_degC
wind_speed_kt = readcsv.Wind_Speed_kt
Wind_Direction = readcsv.Wind_Direction
lat = readcsv.Latitude
lon = readcsv.Longitude
Wind_speed_2 = wind_speed_kt*1.852
# extract U and V components
WG_wind_U = Wind_speed_2 * np.sin((360-Wind_Direction)*np.pi/180)
WG_wind_V = -Wind_speed_2*np.cos((360-Wind_Direction)*np.pi/180)
m = Basemap(projection='merc',llcrnrlat=-32.2,urcrnrlat=-29,\
llcrnrlon=30,urcrnrlon=33,lat_ts=5,resolution='i')
# Create colour bar
norm = matplotlib.colors.Normalize()
norm.autoscale(temp)
cm = matplotlib.cm.CMRmap
sm = matplotlib.cm.ScalarMappable(cmap=cm, norm=norm)
sm.set_array([])
# Plot
q = m.quiver(lon,lat,WG_wind_U,WG_wind_V,color=cm(norm(temp)))
plt.xlabel('Longitude')
plt.ylabel('Latitude')
plt.quiverkey(q,0.9, 0.05, 30, r'$30 \frac{Kp}{h}$',labelpos='W',fontproperties={'size': 15,'weight': 'bold'})
cbar = plt.colorbar(sm)
plt.show()
基本上我需要在这个情节中添加一个海岸线: enter image description here
答案 0 :(得分:1)
fieldTypes