geojson源#
此示例演示了在Bokeh中使用GeoJSON数据创建散点图。
详情
- Sampledata:
- Bokeh APIs:
bokeh.models.GeoJSONDataSource
,bokeh.plotting.figure
,bokeh.plotting.show
- More info:
- Keywords:
地理JSON,散点图,颜色,地图
import json
from bokeh.models import GeoJSONDataSource
from bokeh.plotting import figure, show
from bokeh.sampledata.sample_geojson import geojson
data = json.loads(geojson)
for i in range(len(data['features'])):
data['features'][i]['properties']['Color'] = ['blue', 'red'][i%2]
geo_source = GeoJSONDataSource(geojson=json.dumps(data))
TOOLTIPS = [('Organisation', '@OrganisationName')]
p = figure(background_fill_color="lightgrey", tooltips=TOOLTIPS)
p.scatter(x='x', y='y', size=15, color='Color', alpha=0.7, source=geo_source)
show(p)