the below code works well for plotting circles on a google map image. Blue circles represent origins and red circles represent destinations. The data comes from a csv file, which is imported into a dataframe. The data contains lat/lng coordinates for 10 routes. Again, I am able to plot circles representing the locations easily. But when I add in code to draw segments (lines connecting points), nothing is rendered. No errors are reported when running the script either, which is making it hard to diagnose. I made comments in the code around parts that relate to the segments. Any help would be appreciated.
I am using Bokeh version 0.12.6 and python 3.5
import pandas as pd
from bokeh.io import output_file, show
from bokeh.models import HoverTool, ResetTool, WheelZoomTool
from bokeh.models import GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d,PanTool, Segment
df = pd.read_csv('routes.csv', index_col='Lane')
map_options = GMapOptions(lat=40.29, lng=-97.73, map_type="roadmap", zoom=4)
plot = GMapPlot(x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options,plot_width=800, plot_height=700)
plot.title.text = "Top 10 Routes Over 500 miles"
plot.api_key = "MyKEY"
sourceO=ColumnDataSource(
data=dict(
lat=list(df.Originlat),
lon=list(df.Originlng),
desc=list(df.OriginCity)
)
)
sourceD=ColumnDataSource(
data=dict(
lat=list(df.Destlat),
lon=list(df.Destlng),
desc=list(df.DestCity)
)
)
#data for segments
sourceR=ColumnDataSource(
data=dict(
Originlat= list(df.Originlat),
Originlng=list(df.Originlng),
Destlat=list(df.Destlat),
Destlng=list(df.Destlng),
desc=list(df.index)
)
)
hover = HoverTool(tooltips=[
("", "@desc"),
])
circleO = Circle(x="lon", y="lat", size=15, fill_color="blue", fill_alpha=0.8, line_color='black')
circleD = Circle(x="lon", y="lat", size=15, fill_color="red", fill_alpha=0.8, line_color='black')
#setting the segments
route = Segment(x0='Originlng', y0="Originlat",x1='Destlng', y1="Destlat",line_color="black", line_width=2)
plot.add_glyph(sourceO, circleO)
plot.add_glyph(sourceD, circleD)
#adding segments to plot
plot.add_glyph(sourceR, route)
plot.add_tools(ResetTool(), WheelZoomTool(), PanTool(), hover)
output_file("gmap_plot.html")
show(plot)