-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
usage-pdk.py
61 lines (49 loc) · 1.16 KB
/
usage-pdk.py
1
2
3
4
5
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Adapted from: https://pypi.org/project/pydeck/
"""
import os
import dash
import dash_deck
import dash_html_components as html
import pydeck as pdk
import pandas as pd
mapbox_api_token = os.getenv("MAPBOX_ACCESS_TOKEN")
# 2014 locations of car accidents in the UK
UK_ACCIDENTS_DATA = (
"https://raw.githubusercontent.com/uber-common/"
"deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv"
)
# Define a layer to display on a map
layer = pdk.Layer(
"HexagonLayer",
UK_ACCIDENTS_DATA,
get_position=["lng", "lat"],
auto_highlight=True,
elevation_scale=50,
pickable=True,
elevation_range=[0, 3000],
extruded=True,
coverage=1,
)
# Set the viewport location
view_state = pdk.ViewState(
longitude=-1.415,
latitude=52.2323,
zoom=6,
min_zoom=5,
max_zoom=15,
pitch=40.5,
bearing=-27.36,
)
# Render
r = pdk.Deck(
layers=[layer],
initial_view_state=view_state,
api_keys={"mapbox": mapbox_api_token},
)
app = dash.Dash(__name__)
app.layout = html.Div(
dash_deck.DeckGL(r.to_json(), id="deck-gl", tooltip=True, mapboxKey=r.mapbox_key)
)
if __name__ == "__main__":
app.run_server(debug=True)