Great Circle lines in Bokeh

Is it possible to plot lines between points on a map in Bokeh and have them follow great circles. Examples of what I’m interested in trying to do in Bokeh are: https://plot.ly/pandas/lines-on-maps/ ideally also using a local vector world map rather than the GMapPlot, which isn’t working consistently for me in 11.1.

Hey Elijah,

Yes. To start, I think a good approach is to use common python tools to create the geodesic line (pyproj) and then plot it. Below shows creating a geodesic line from SFO airport to JFK airport and then plotting it as a line glyph. Notice the tolerance argument which you can increase to make the line coarser, or decrease to make the line smoother.

from bokeh.io import output_file, show
from bokeh.plotting import Figure
import pyproj

def create_geodesic_line(start_point, end_point, tolerance=1000):
start_x, start_y = start_point
end_x, end_y = end_point
g = pyproj.Geod(ellps=‘WGS84’)
az12, az21, dist = g.inv(start_x, start_y, end_x, end_y)
coords = g.npts(start_x, start_y, end_x, end_y, 1 + int(dist / tolerance))
coords.insert(0, (start_x, start_y))
coords.append((end_x, end_y))
return zip(*coords)

jfk = (-73.7781, 40.6413)
sfo = (-122.3790, 37.6213)

xs, ys = create_geodesic_line(sfo, jfk, tolerance=10000)
fig = Figure(x_range=(-180, 180), y_range=(-90, 90))
fig.line(x=xs, y=ys, color=‘blue’)

output_file(‘geodesic_line_example.html’)
show(fig)

``

You also have other options within Bokeh besides GMapPlot, which include using one of the canned Stamen map providers from bokeh.tile_providers, or adding a GeoJSON file to provide context using GeoJSONDataSource. If you were to use a Web Mercator basemap, then you would need to use pyproj to convert points/lines from WGS84 (ESPG:4326) to Web Mercator (ESPG:3857).

···

On Wednesday, April 13, 2016 at 12:16:13 AM UTC-5, Elijah U wrote:

Is it possible to plot lines between points on a map in Bokeh and have them follow great circles. Examples of what I’m interested in trying to do in Bokeh are: https://plot.ly/pandas/lines-on-maps/ ideally also using a local vector world map rather than the GMapPlot, which isn’t working consistently for me in 11.1.