반응형
/*******************************************************************************************************************
-- Title : [Py3.5] Plotting Coordinates in Basemap w/ Matplotlib
-- Reference : pythonprogramming.net
-- Key word : python 파이썬 matplotlib pyplot basemap mpl toolkits mpl_toolkits drawgreatcircle
*******************************************************************************************************************/
-- Figure
-- Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt m = Basemap(projection='mill', llcrnrlat = 25, llcrnrlon = -130, urcrnrlat = 50, urcrnrlon = -60, resolution='l') # -- 라인 표기 m.drawcoastlines() # 해안선 표기 m.drawcountries(linewidth=2) # 국경선 표기 m.drawstates(color='b') # State선 표기 xs = [] ys = [] # -- NY 위도/경도 설정 NYClat, NYClon = 40.7127, -74.0059 xpt, ypt = m(NYClon, NYClat) # 좌표로 변환 xs.append(xpt) # [6226256.9101838665] ys.append(ypt) # [1954505.7853856701] # print(xs) # print(ys) m.plot(xpt, ypt, 'c*', markersize=15) # -- LA 위도/경도 설정 LAlat, LAlon = 34.05, -118.25 xpt, ypt = m(LAlon, LAlat) xs.append(xpt) # [6226256.9101838665, 1306539.7728450038] ys.append(ypt) # [1954505.7853856701, 1099340.1932921838] # print(xs) # print(ys) # -- 플로팅 m.plot(xpt, ypt, 'g^', markersize=15) m.plot(xs, ys, color='r', linewidth=3, label='Flight 98') # 선 그리기 m.drawgreatcircle(NYClon, NYClat, LAlon, LAlat, color='c', linewidth=3, label='Arc') # 곡선 그리기 plt.legend(loc=4) plt.title('Basemap Tutorial') plt.show() | cs |
반응형