如果不知道区域边界,如何使用Bokeh创建Choropleth贴图

问题描述 投票:0回答:1

我有以下几列的坐标数据:lat | lon | hits

我想在OSM方块的顶部,根据点击率使用这些数据绘制带有颜色的色度。

plot = figure(
    tools= "pan,wheel_zoom",
    x_range=[8580732.740161393, 8694052.230954666],
    y_range=[3324832.84084286, 3580909.760461876])
plot.add_tile(get_provider(Vendors.OSM))

到目前为止,我了解到我们需要有色区域的边界,但是在印度较小城市中,我没有针对地理位置边界的geojson。有什么方法可以使用正方形/矩形网格或将坐标聚类来绘制节流图?

python bokeh openstreetmap folium choropleth
1个回答
0
投票

Bokeh中唯一可以进行自动合并的是hexbin

import numpy as np
from bokeh.plotting import figure, show

n = 500
x = 2 + 2*np.random.standard_normal(n)
y = 2 + 2*np.random.standard_normal(n)

p = figure(match_aspect=True, background_fill_color='#440154')
p.grid.visible = False

r, bins = p.hexbin(x, y, size=0.5, hover_color="pink", hover_alpha=0.8)

p.circle(x, y, color="white", size=1)

show(p)

enter image description here

如果您还需要除十六进制图块之外的其他内容,则必须明确定义所需的边界/区域,然后自己在其中进行分类。

© www.soinside.com 2019 - 2024. All rights reserved.