Good afternoon, I have been attempting to create a bounding box for a region on a GMapPlot using minima and maxima of a geographical location. For example, if I wanted to create a bounding box of the island of Oahu, I would take the minima and maxima of lat, long coordinate pairs and outline the island in red. I have the following code snippet to illustrate this. The code yields no errors but does not create a bounding box.
from future import print_function
from bokeh.plotting import *
from bokeh import session
import os.path
import pandas as pd
from bokeh.models.glyphs import Circle, Line
from bokeh.models import(
GMapPlot, Range1d, ColumnDataSource, LinearAxis,
PanTool, WheelZoomTool, BoxZoomTool, ResetTool, ResizeTool, BoxSelectTool, HoverTool,
BoxSelectionOverlay, GMapOptions,
NumeralTickFormatter, PrintfTickFormatter)
from bokeh.resources import INLINE
output_notebook()
‘’’
code omitted that creates a 1 row dataframe called “row” from survey data for the sake of anonymity. Similarly the title and
actual gps points of the map have been changed.
‘’’
x_range = Range1d()
y_range = Range1d()
map_options = GMapOptions(lat= 21.28, lng=157.59, zoom=11)
plot = GMapPlot(
x_range = x_range,
y_range = y_range,
map_options=map_options,
title = “Oahu”
)
plot.map_options.map_type=“terrain”
source = ColumnDataSource(
data=dict(
x=[row[“gps_lat_min”],row[“gps_lat_max”],row[“gps_lat_max”],row[“gps_lat_min”]],
y=[row[“gps_lon_min”],row[“gps_lon_min”],row[“gps_lon_max”],row[“gps_lon_max”]]
)
)
#line width has been replaced with .02 and .5, neither of which yield results
line = Line(x=“x”,y=“y”, line_color = “red”, line_width=.5)
plot.add_glyph(source, line)
pan = PanTool()
wheel_zoom = WheelZoomTool()
box_zoom = BoxZoomTool()
plot.add_tools(pan, wheel_zoom, box_zoom, )
xaxis = LinearAxis(axis_label=“lon.”, major_tick_in=0)
plot.add_layout(xaxis, ‘below’)
yaxis = LinearAxis(axis_label=“lat.”, major_tick_in=0)
plot.add_layout(yaxis, ‘left’)
show(plot)
``
``
Is there a better way to accomplish what I am attempting? Thank you for your assistance. I am sorry if this does not suffice as a minimum working example.