A heatmap like overlay on top of a map

Alright, I am able to take some GeoJSON data and generate a world map with country labels like so:

from bokeh.io import output_notebook, show
from bokeh.models import GeoJSONDataSource, HoverTool
from bokeh.plotting import figure
from bokeh.sampledata.sample_geojson import geojson
import requests
import json

Notebook output

output_notebook()

geojson = ‘’.join(open(‘countries-hires.json’, ‘r’, encoding=‘latin-1’).readlines())
geo_source = GeoJSONDataSource(geojson=geojson)

p = figure(height=900, width=1200)
p.patches(xs=‘xs’, ys=‘ys’, fill_color = “white”, fill_alpha=0.7, source=geo_source)
p.multi_line(xs=‘xs’, ys=‘ys’, line_color=‘black’, line_width=0.1, source=geo_source)
p.add_tools(HoverTool(tooltips=[(
“Country”, “@SOVEREIGNT
)]))

show(p)

``

Now I want to overlay on top of that a heatmap or a heatmap like graph from a dataframe.

Basically I’d like all the countries with a number attribute to be shaded with a darker red as that attribute gets higher, and less red as it is lower. I’d then like to add the HoverTool with that exact value.

Can I do this?

I’m not sure if I need to create patches or hexbins or what? (or this is not even possible).

Any help would be really appreciated! I apologize for the flurry of questions. I’m a n00b.

-aps

After A LOT of experimentation and some reading, it seems like patches were the order of the day! bokeh is awesome!

-aps

···

On Monday, November 26, 2018 at 7:53:11 PM UTC-5, pisymbol wrote:

Alright, I am able to take some GeoJSON data and generate a world map with country labels like so:

from bokeh.io import output_notebook, show
from bokeh.models import GeoJSONDataSource, HoverTool
from bokeh.plotting import figure
from bokeh.sampledata.sample_geojson import geojson
import requests
import json

Notebook output

output_notebook()

geojson = ‘’.join(open(‘countries-hires.json’, ‘r’, encoding=‘latin-1’).readlines())
geo_source = GeoJSONDataSource(geojson=geojson)

p = figure(height=900, width=1200)
p.patches(xs=‘xs’, ys=‘ys’, fill_color = “white”, fill_alpha=0.7, source=geo_source)
p.multi_line(xs=‘xs’, ys=‘ys’, line_color=‘black’, line_width=0.1, source=geo_source)
p.add_tools(HoverTool(tooltips=[(
“Country”, “@SOVEREIGNT
)]))

show(p)

``