[英]Plot ConvexHull in basemap
我正在通過一組緯度和縱向位置在python中制作一個ConvexHull。 然后,我想在底圖中的ConvexHull旁邊繪制點。 如果我按照http://docs.scipy.org/doc/scipy/reference/generation/scipy.spatial.ConvexHull.html#scipy.spatial中的說明進行操作,但如果我在沒有地圖的法線圖中繪制它們,則一切正常。 .ConvexHull 。 當我嘗試用底圖繪制它們時,我只是得到了常規圖。 我做錯了什么?
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
map = Basemap(projection='merc',
resolution = 'c', area_thresh = 40,
llcrnrlon=27.72, llcrnrlat=69.41,
urcrnrlon=28.416, urcrnrlat=70.95)
con = lite.connect(databasepath)
with con:
cur = con.execute("SELECT DISTINCT latitude, longitude FROM MessageType1 where latitude>= 70.55 and latitude<= 70.7 and longitude >= 27.72 and longitude <= 28.416 limit 100 ")
points = [[float(x[1]), float(x[0])] for x in cur]
points = np.array(points)
hull = ConvexHull(points)
x,y = map(points[:,0], points[:,1])
plt.plot(x, y, 'o')
for simplex in hull.simplices:
x,y = map(points[simplex,0], points[simplex,1])
plt.plot(x,y, 'k-')
plt.show()
設置底圖以繪制地圖要素后,需要添加一些方法。 例如:
map.drawcoastlines()
map.drawstates()
map.drawcountries()
map.drawmapboundary()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.