如何将散景图像叠加到散景GMap?

时间:2015-11-12 17:01:10

标签: python data-visualization bokeh

假设这个x和y in this example是纬度和经度值。如何将其叠加在GMap上(即the one in this notebook)。

我有我的GMap:

p = GMapPlot(
    x_range=Range1d(-160, 160), y_range=Range1d(-80, 80),
    plot_width=1000,plot_height=700,
    map_options=GMapOptions(lat=48.77, lng=9.18, zoom=4),
    title="Cities with more than 5,000 people",
    webgl=True, responsive=True)

我有一个数组可以创建我的图像及其网格:

m1 = df['longitude'].values
m2 = df['latitude'].values

xmin = m1.min()
xmax = m1.max()
ymin = m2.min()
ymax = m2.max()

X, Y = np.mgrid[xmin:xmax:1000j, ymin:ymax:1000j]
positions = np.vstack([X.ravel(), Y.ravel()])
values = np.vstack([m1, m2])
kernel = stats.gaussian_kde(values)
Z = np.reshape(kernel(positions).T, X.shape)

N = 1000

x = np.linspace(xmin, xmax, N)
y = np.linspace(ymin, ymax, N)

xx, yy = np.meshgrid(x, y)

c = figure(x_range=[xmin, xmax], y_range=[ymin, ymax])
c.image(image=[Z], x=[xmin], y=[ymin], dw=[xmax-xmin], dh=[ymax-ymin], palette="Spectral11")

show(c)  # open a browser

如何在p?

之上绘制c?

1 个答案:

答案 0 :(得分:0)

这是我的代码片段。希望你发现它很有用

df_lat = df["LATITUDE"]
df_lon = df["LONGITUDE"]
lat = df_lat.tolist()
lon = df_lon.tolist()

source = ColumnDataSource(
        data=dict(
            lat = lat,
            lon = lon,
        )
    )
circle = Circle(x="lon", y="lat", size=5, fill_color = 'fill', fill_alpha=0.8, line_color='black')
    plot.add_glyph(source, circle)
plot.add_tools(PreviewSaveTool(), WheelZoomTool(),ResizeTool())
show(plot)