用matplotlib绘制线时“未定义的反短程线”

时间:2018-07-03 13:18:50

标签: python matplotlib charts inverse valueerror

这是我现在正在使用的示例代码:https://python-graph-gallery.com/300-draw-a-connection-line/

当我使用示例坐标时,它可以正常工作,并且像示例中一样绘制橙色线。

但是,当我输入自己的坐标而不是样本坐标时,会产生ValueError。

这是我的代码的外观:

m=Basemap()

m.drawmapboundary(fill_color='#A6CAE0', linewidth=0)
m.fillcontinents(color='grey', alpha=0.7, lake_color='grey')
m.drawcoastlines(linewidth=0.1, color="white")

# Add a connection between new york and London
startlat = 40.78; startlon = -73.98
arrlat = 51.53; arrlon = 0.08

m.drawgreatcircle(59.33, 18.07, 35.3, 149.1, linewidth=2, color='orange')

这是它产生的全部错误:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-b3f6087641a6> in <module>()
     14 print(end)
     15 m.drawgreatcircle(startlon,startlat,arrlon,arrlat, linewidth=4, color='orange')
---> 16 m.drawgreatcircle(59.33, 18.07, 35.3, 149.1, linewidth=2, color='orange')

~\AppData\Local\conda\conda\envs\LocalEnv\lib\site-packages\mpl_toolkits\basemap\__init__.py in drawgreatcircle(self, lon1, lat1, lon2, lat2, del_s, **kwargs)
   2875         # use great circle formula for a perfect sphere.
   2876         gc = pyproj.Geod(a=self.rmajor,b=self.rminor)
-> 2877         az12,az21,dist = gc.inv(lon1,lat1,lon2,lat2)
   2878         npoints = int((dist+0.5*1000.*del_s)/(1000.*del_s))
   2879         lonlats = gc.npts(lon1,lat1,lon2,lat2,npoints)

~\AppData\Local\conda\conda\envs\LocalEnv\lib\site-packages\pyproj\__init__.py in inv(self, lons1, lats1, lons2, lats2, radians)
    826         inz, zisfloat, zislist, zistuple = _copytobuffer(lons2)
    827         ind, disfloat, dislist, distuple = _copytobuffer(lats2)
--> 828         _proj.Geod._inv(self,inx,iny,inz,ind,radians=radians)
    829         # if inputs were lists, tuples or floats, convert back.
    830         outx = _convertback(xisfloat,xislist,xistuple,inx)

_proj.pyx in _proj.Geod._inv (_proj.c:5471)()

ValueError: undefined inverse geodesic (may be an antipodal point)

有人看到问题出在哪里吗?

预先感谢

0 个答案:

没有答案