Spaces:
Runtime error
Runtime error
MarcSkovMadsen
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,54 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
import
|
4 |
|
|
|
|
|
5 |
import panel as pn
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
)
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
)
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
|
|
30 |
|
31 |
-
|
|
|
|
|
32 |
|
33 |
-
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
"""
|
37 |
|
38 |
-
pn.
|
39 |
-
|
40 |
-
site_url="https://awesome-panel.org",
|
41 |
-
logo="https://panel.holoviz.org/_static/logo_horizontal_dark_theme.png",
|
42 |
-
title="mapwidget.cesium",
|
43 |
-
theme="dark",
|
44 |
-
theme_toggle=False,
|
45 |
-
main_layout=None,
|
46 |
-
main=[component],
|
47 |
-
sidebar=[description],
|
48 |
-
).servable()
|
|
|
1 |
+
import numpy as np
|
2 |
+
import holoviews as hv
|
3 |
+
import dask.dataframe as dd
|
4 |
|
5 |
+
from holoviews import opts
|
6 |
+
from holoviews.operation.datashader import aggregate
|
7 |
import panel as pn
|
8 |
+
from utils import get_meta_data
|
9 |
+
|
10 |
+
pn.extension()
|
11 |
+
|
12 |
+
hv.extension('bokeh')
|
13 |
|
14 |
+
renderer = hv.renderer('bokeh')
|
15 |
|
16 |
+
opts.defaults(
|
17 |
+
opts.Curve(xaxis=None, yaxis=None, show_grid=False, show_frame=False,
|
18 |
+
color='orangered', framewise=True, width=100),
|
19 |
+
opts.Image(width=800, height=400, shared_axes=False, logz=True, colorbar=True,
|
20 |
+
xaxis=None, yaxis=None, axiswise=True, bgcolor='black'),
|
21 |
+
opts.HLine(color='white', line_width=1),
|
22 |
+
opts.Layout(shared_axes=False),
|
23 |
+
opts.VLine(color='white', line_width=1))
|
24 |
|
25 |
+
pandas_df = pn.cache(get_meta_data)()
|
26 |
+
df = dd.from_pandas(pandas_df).persist()
|
|
|
27 |
|
28 |
+
points = hv.Points(df, kdims=['centre_easting', 'centre_northing'], vdims=[])
|
29 |
|
30 |
+
agg = aggregate(points, link_inputs=True, x_sampling=0.0001, y_sampling=0.0001)
|
31 |
|
32 |
+
agg.opts(cmap="kr_r")
|
33 |
|
34 |
+
pointerx = hv.streams.PointerX(x=np.mean(points.range('centre_easting')), source=points)
|
35 |
+
pointery = hv.streams.PointerY(y=np.mean(points.range('centre_northing')), source=points)
|
36 |
+
box = hv.streams.BoundsXY(source=points, bounds=(0,0,0,0))
|
37 |
+
vline = hv.DynamicMap(lambda x: hv.VLine(x), streams=[pointerx])
|
38 |
+
hline = hv.DynamicMap(lambda y: hv.HLine(y), streams=[pointery])
|
39 |
|
40 |
+
tiles = hv.Tiles('https://tile.openstreetmap.org/{Z}/{X}/{Y}.png', name="OSM").opts(width=600, height=550)
|
41 |
+
hvobj = tiles * agg * hline * vline
|
42 |
|
43 |
+
@pn.depends(pointerx.param.x, pointery.param.y)
|
44 |
+
def table(x,y):
|
45 |
+
return f"Easting: {x}, Northing: {y}"
|
46 |
|
47 |
+
@pn.depends(box.param.bounds)
|
48 |
+
def bbox(value):
|
49 |
+
return str(value)
|
50 |
|
51 |
+
pn.pane.HoloViews(hvobj).servable()
|
|
|
52 |
|
53 |
+
pn.panel(table).servable()
|
54 |
+
pn.panel(bbox).servable()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|