I’ve encountered an issue with plotting map data, and I’m not quite sure what I’m doing wrong here.
Here’s a fairly self-contained example of what I’m trying to do:
import pandas as pd
from bokeh.models import ColumnDataSource, Range1d, Circle
from bokeh.plotting import figure, show
sprays = pd.read_csv(‘http://bostonopendata-boston.opendata.arcgis.com/datasets/5409b7735d384798b2a360aa47c9b128_0.csv’)
sprays.head()
src = ColumnDataSource(sprays)
x_range = Range1d(start=-20E6, end=20E6, bounds=None)
y_range = Range1d(start=-20E6, end=20E6, bounds=None)
p = figure(x_range=x_range, y_range=y_range)
p.axis.visible = False
circs = Circle(x=‘X’, y=‘Y’, size=10, line_color=None, fill_alpha=0.8, fill_color=“blue”, )
p.add_glyph(src, circs)
p.add_tile(STAMEN_TONER)
show(p)
``
The problems I’m encountering are as follows:
- The data points are not aligned on the correct portion of the map; they all show up near the equator, near a “null island”. These are all data points from Boston, so I though they would automatically line up on Boston when I add the stamen toner tile, but I must be missing something here.
- If I take out x_range and y_range from the figure constructor, then the STAMEN_TONER tile doesn’t show up on the figure. I can clearly see that the data points are plotted correctly relative to one another.
I think I might need some educating here - what’s missing from my mental model of Bokeh’s underpinnings? Also, what’s the right thing to do to get the data points mapped onto Boston?
