Spaces:
Runtime error
Runtime error
import numpy as np | |
import holoviews as hv | |
import dask.dataframe as dd | |
from holoviews import opts | |
from holoviews.operation.datashader import aggregate | |
import panel as pn | |
from utils import get_meta_data | |
pn.extension() | |
hv.extension('bokeh') | |
renderer = hv.renderer('bokeh') | |
opts.defaults( | |
opts.Curve(xaxis=None, yaxis=None, show_grid=False, show_frame=False, | |
color='orangered', framewise=True, width=100), | |
opts.Image(width=800, height=400, shared_axes=False, logz=True, colorbar=True, | |
xaxis=None, yaxis=None, axiswise=True, bgcolor='black'), | |
opts.HLine(color='white', line_width=1), | |
opts.Layout(shared_axes=False), | |
opts.VLine(color='white', line_width=1)) | |
pandas_df = pn.cache(get_meta_data)() | |
df = dd.from_pandas(pandas_df).persist() | |
points = hv.Points(df, kdims=['centre_easting', 'centre_northing'], vdims=[]) | |
agg = aggregate(points, link_inputs=True, x_sampling=0.0001, y_sampling=0.0001) | |
agg.opts(cmap="kr_r") | |
pointerx = hv.streams.PointerX(x=np.mean(points.range('centre_easting')), source=points) | |
pointery = hv.streams.PointerY(y=np.mean(points.range('centre_northing')), source=points) | |
box = hv.streams.BoundsXY(source=points, bounds=(0,0,0,0)) | |
vline = hv.DynamicMap(lambda x: hv.VLine(x), streams=[pointerx]) | |
hline = hv.DynamicMap(lambda y: hv.HLine(y), streams=[pointery]) | |
tiles = hv.Tiles('https://tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="OSM").opts(width=600, height=550) | |
hvobj = tiles * agg * hline * vline | |
def table(x,y): | |
return f"Easting: {x}, Northing: {y}" | |
def bbox(value): | |
return str(value) | |
pn.pane.HoloViews(hvobj).servable() | |
pn.panel(table).servable() | |
pn.panel(bbox).servable() |