Question

I am trying to plot a great circle between the mean on a collection of points and a second point. However the great circle path is incorrect when I use the mean, but is right if I use a predefined variable that is the same as the mean. An example is below.

from mpl_toolkits.basemap import Basemap
import pyproj
from pylab import *

# setup basemap.
lat_1 = 49.5
lat_2 = 55.5
lat_0 = 52.5
lon_1 = -16.5
lon_2 = -1.0
lon_0 = -5.25


m = Basemap(llcrnrlon=lon_1,llcrnrlat=lat_1,urcrnrlon=lon_2,urcrnrlat=lat_2,
        resolution='i',projection='lcc',lon_0=lon_0,lat_0=lat_0)        
m.drawcoastlines()

lon1 = -8.2395881636363644
lat1 = 54.876441136363631

lons = [-8.3771698, -8.177818, -8.2758546, -8.2197834, -8.3409037, -8.247925, -8.3208079, -8.3288984, -8.1521259, -8.0139167, -8.1802664]
lats = [54.9846137, 54.8639587, 54.8730255, 54.89845, 54.9096928, 54.9390132, 54.7620135, 54.8300078, 54.8883947, 54.8743167, 54.8173659]

clon = mean(lons)
clat = mean(lats)

g = pyproj.Geod(ellps='WGS84')
az = 261.0
lon2, lat2, baz1 = g.fwd(lon1, lat1, az, 1000000)

m.drawgreatcircle(lon1, lat1, lon2, lat2, del_s=0.1)
m.drawgreatcircle(clon, clat, lon2, lat2, del_s=0.1)

clon==lon1
clat==lat1

Does anyone know what the problem is??

Was it helpful?

Solution

>>> type(clon)
<type 'numpy.float64'>
>>> type(lon1)
<type 'float'>

Probably drawgreatcircle() doesn't know what to do with numpy.float64, so convert it to a regular float with

>>> clon = float(clon)
>>> type(clon)
<type 'float'>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top