使用matplotlib绘制直线时的“未定义的反测地线”

2024-06-17 10:55:26 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我现在使用的示例代码: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)

有人知道问题出在哪里吗?你知道吗

提前谢谢


Tags: inself示例condacolorprojvalueerrororange