giswqs commited on
Commit
f42f303
1 Parent(s): bd01bd5

Added sample data

Browse files
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  from multiapp import MultiApp
3
- from apps import home
4
 
5
  # st.set_page_config(layout="wide")
6
 
@@ -9,6 +9,7 @@ apps = MultiApp()
9
 
10
  # Add all your application here
11
 
 
12
  apps.add_app("Home", home.app)
13
 
14
  # The main app
 
1
  import streamlit as st
2
  from multiapp import MultiApp
3
+ from apps import home, deck
4
 
5
  # st.set_page_config(layout="wide")
6
 
 
9
 
10
  # Add all your application here
11
 
12
+ apps.add_app("pydeck", deck.app)
13
  apps.add_app("Home", home.app)
14
 
15
  # The main app
apps/deck.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+
4
+ def app():
5
+
6
+ import pydeck as pdk
7
+
8
+ DATA_URL = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json"
9
+ LAND_COVER = [
10
+ [[-123.0, 49.196], [-123.0, 49.324], [-123.306, 49.324], [-123.306, 49.196]]
11
+ ]
12
+
13
+ INITIAL_VIEW_STATE = pdk.ViewState(
14
+ latitude=49.254, longitude=-123.13, zoom=11, max_zoom=16, pitch=45, bearing=0
15
+ )
16
+
17
+ polygon = pdk.Layer(
18
+ "PolygonLayer",
19
+ LAND_COVER,
20
+ stroked=False,
21
+ # processes the data as a flat longitude-latitude pair
22
+ get_polygon="-",
23
+ get_fill_color=[0, 0, 0, 20],
24
+ )
25
+
26
+ geojson = pdk.Layer(
27
+ "GeoJsonLayer",
28
+ DATA_URL,
29
+ opacity=0.8,
30
+ stroked=False,
31
+ filled=True,
32
+ extruded=True,
33
+ wireframe=True,
34
+ get_elevation="properties.valuePerSqm / 20",
35
+ get_fill_color="[255, 255, properties.growth * 255]",
36
+ get_line_color=[255, 255, 255],
37
+ )
38
+
39
+ r = pdk.Deck(
40
+ layers=[polygon, geojson],
41
+ initial_view_state=INITIAL_VIEW_STATE,
42
+ height=1000,
43
+ width="100%",
44
+ )
45
+
46
+ st.pydeck_chart(r)
data/us_counties.geojson ADDED
The diff for this file is too large to render. See raw diff
 
data/us_metro_areas.geojson ADDED
The diff for this file is too large to render. See raw diff
 
data/us_nation.geojson ADDED
The diff for this file is too large to render. See raw diff
 
data/us_states.geojson ADDED
The diff for this file is too large to render. See raw diff
 
notebooks/pydeck.ipynb ADDED
@@ -0,0 +1,417 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 24,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/html": [
11
+ "\n",
12
+ " <iframe\n",
13
+ " width=\"100%\"\n",
14
+ " height=500\n",
15
+ " frameborder=\"0\"\n",
16
+ " srcdoc=\"&lt;!DOCTYPE html&gt;\n",
17
+ "&lt;html&gt;\n",
18
+ " &lt;head&gt;\n",
19
+ " &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
20
+ " &lt;title&gt;pydeck&lt;/title&gt;\n",
21
+ " &lt;script src=&quot;https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js&quot;&gt;&lt;/script&gt;\n",
22
+ " &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot; /&gt;\n",
23
+ " &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot; /&gt;\n",
24
+ " &lt;script src=&#x27;https://cdn.jsdelivr.net/npm/@deck.gl/jupyter-widget@~8.5.*/dist/index.js&#x27;&gt;&lt;/script&gt;\n",
25
+ " &lt;style&gt;\n",
26
+ " body {\n",
27
+ " margin: 0;\n",
28
+ " padding: 0;\n",
29
+ " overflow: hidden;\n",
30
+ "}\n",
31
+ "\n",
32
+ "#deck-map-container {\n",
33
+ " width: 100%;\n",
34
+ " height: 100%;\n",
35
+ " background-color: black;\n",
36
+ "}\n",
37
+ "\n",
38
+ "#map {\n",
39
+ " pointer-events: none;\n",
40
+ " height: 100%;\n",
41
+ " width: 100%;\n",
42
+ " position: absolute;\n",
43
+ " z-index: 1;\n",
44
+ "}\n",
45
+ "\n",
46
+ "#deckgl-overlay {\n",
47
+ " z-index: 2;\n",
48
+ " background: none;\n",
49
+ "}\n",
50
+ "\n",
51
+ "#deck-map-wrapper {\n",
52
+ " width: 100%;\n",
53
+ " height: 100%;\n",
54
+ "}\n",
55
+ "\n",
56
+ "#deck-container {\n",
57
+ " width: 100vw;\n",
58
+ " height: 100vh;\n",
59
+ "}\n",
60
+ " &lt;/style&gt;\n",
61
+ " &lt;/head&gt;\n",
62
+ " &lt;body&gt;\n",
63
+ " &lt;div id=&quot;deck-container&quot;&gt;\n",
64
+ " &lt;/div&gt;\n",
65
+ " &lt;/body&gt;\n",
66
+ " &lt;script&gt;\n",
67
+ " const jsonInput = {&quot;initialViewState&quot;: {&quot;bearing&quot;: 0, &quot;latitude&quot;: 1, &quot;longitude&quot;: 0, &quot;maxZoom&quot;: 16, &quot;pitch&quot;: 45, &quot;zoom&quot;: 0}, &quot;layers&quot;: [{&quot;@@type&quot;: &quot;GeoJsonLayer&quot;, &quot;data&quot;: &quot;https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson&quot;, &quot;extruded&quot;: true, &quot;filled&quot;: true, &quot;getElevation&quot;: &quot;@@=properties.POP_EST/300&quot;, &quot;getFillColor&quot;: &quot;@@=[255, 255, 0]&quot;, &quot;getLineColor&quot;: [255, 255, 255], &quot;id&quot;: &quot;b1b3fd43-09d9-4ad1-baec-4a80d8599fee&quot;, &quot;opacity&quot;: 0.3, &quot;stroked&quot;: false, &quot;wireframe&quot;: true}], &quot;mapProvider&quot;: &quot;carto&quot;, &quot;mapStyle&quot;: &quot;https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json&quot;, &quot;views&quot;: [{&quot;@@type&quot;: &quot;MapView&quot;, &quot;controller&quot;: true}]};\n",
68
+ " const tooltip = true;\n",
69
+ " const customLibraries = null;\n",
70
+ "\n",
71
+ " const deckInstance = createDeck({\n",
72
+ " mapboxApiKey: &#x27;pk.eyJ1IjoiZ2lzd3FzIiwiYSI6ImNqbWg2YWlpeTA0aGkzdXJ0aWs3YzBta2gifQ.o8KckhuMI8ef8JDIBoqJ3Q&#x27;,\n",
73
+ " container: document.getElementById(&#x27;deck-container&#x27;),\n",
74
+ " jsonInput,\n",
75
+ " tooltip,\n",
76
+ " customLibraries\n",
77
+ " });\n",
78
+ "\n",
79
+ " &lt;/script&gt;\n",
80
+ "&lt;/html&gt;\"\n",
81
+ " ></iframe>\n",
82
+ " "
83
+ ],
84
+ "text/plain": [
85
+ "{\"initialViewState\": {\"bearing\": 0, \"latitude\": 1, \"longitude\": 0, \"maxZoom\": 16, \"pitch\": 45, \"zoom\": 0}, \"layers\": [{\"@@type\": \"GeoJsonLayer\", \"data\": \"https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson\", \"extruded\": true, \"filled\": true, \"getElevation\": \"@@=properties.POP_EST/300\", \"getFillColor\": \"@@=[255, 255, 0]\", \"getLineColor\": [255, 255, 255], \"id\": \"b1b3fd43-09d9-4ad1-baec-4a80d8599fee\", \"opacity\": 0.3, \"stroked\": false, \"wireframe\": true}], \"mapProvider\": \"carto\", \"mapStyle\": \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\", \"views\": [{\"@@type\": \"MapView\", \"controller\": true}]}"
86
+ ]
87
+ },
88
+ "execution_count": 24,
89
+ "metadata": {},
90
+ "output_type": "execute_result"
91
+ }
92
+ ],
93
+ "source": [
94
+ "import pydeck as pdk\n",
95
+ "\n",
96
+ "DATA_URL = \"https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson\"\n",
97
+ "\n",
98
+ "INITIAL_VIEW_STATE = pdk.ViewState(latitude=1, longitude=0, zoom=0, max_zoom=16, pitch=45, bearing=0)\n",
99
+ "\n",
100
+ "\n",
101
+ "geojson = pdk.Layer(\n",
102
+ " \"GeoJsonLayer\",\n",
103
+ " DATA_URL,\n",
104
+ " opacity=0.3,\n",
105
+ " stroked=False,\n",
106
+ " filled=True,\n",
107
+ " extruded=True,\n",
108
+ " wireframe=True,\n",
109
+ " get_elevation=\"properties.POP_EST/300\",\n",
110
+ " get_fill_color=\"[255, 255, 0]\",\n",
111
+ " get_line_color=[255, 255, 255],\n",
112
+ ")\n",
113
+ "\n",
114
+ "r = pdk.Deck(layers=[geojson], initial_view_state=INITIAL_VIEW_STATE, width=400)\n",
115
+ "r"
116
+ ]
117
+ },
118
+ {
119
+ "cell_type": "code",
120
+ "execution_count": null,
121
+ "metadata": {},
122
+ "outputs": [],
123
+ "source": [
124
+ "geojson.opacity=0.5"
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "code",
129
+ "execution_count": null,
130
+ "metadata": {},
131
+ "outputs": [],
132
+ "source": [
133
+ "r.update()"
134
+ ]
135
+ },
136
+ {
137
+ "cell_type": "code",
138
+ "execution_count": null,
139
+ "metadata": {},
140
+ "outputs": [],
141
+ "source": [
142
+ "r"
143
+ ]
144
+ },
145
+ {
146
+ "cell_type": "code",
147
+ "execution_count": null,
148
+ "metadata": {},
149
+ "outputs": [],
150
+ "source": [
151
+ "import pydeck as pdk\n",
152
+ "\n",
153
+ "# 2014 locations of car accidents in the UK\n",
154
+ "UK_ACCIDENTS_DATA = ('https://raw.githubusercontent.com/uber-common/'\n",
155
+ " 'deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv')\n",
156
+ "\n",
157
+ "# Define a layer to display on a map\n",
158
+ "layer = pdk.Layer(\n",
159
+ " 'HexagonLayer',\n",
160
+ " UK_ACCIDENTS_DATA,\n",
161
+ " get_position=['lng', 'lat'],\n",
162
+ " auto_highlight=True,\n",
163
+ " elevation_scale=50,\n",
164
+ " pickable=True,\n",
165
+ " elevation_range=[0, 3000],\n",
166
+ " extruded=True, \n",
167
+ " coverage=1)\n",
168
+ "\n",
169
+ "# Set the viewport location\n",
170
+ "view_state = pdk.ViewState(\n",
171
+ " longitude=-1.415,\n",
172
+ " latitude=52.2323,\n",
173
+ " zoom=6,\n",
174
+ " min_zoom=5,\n",
175
+ " max_zoom=15,\n",
176
+ " pitch=40.5,\n",
177
+ " bearing=-27.36)\n",
178
+ "\n",
179
+ "# Render\n",
180
+ "r = pdk.Deck(layers=[layer], initial_view_state=view_state)"
181
+ ]
182
+ },
183
+ {
184
+ "cell_type": "code",
185
+ "execution_count": null,
186
+ "metadata": {},
187
+ "outputs": [],
188
+ "source": [
189
+ "r"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "code",
194
+ "execution_count": null,
195
+ "metadata": {},
196
+ "outputs": [],
197
+ "source": [
198
+ "import pandas as pd"
199
+ ]
200
+ },
201
+ {
202
+ "cell_type": "code",
203
+ "execution_count": null,
204
+ "metadata": {},
205
+ "outputs": [],
206
+ "source": [
207
+ "df = pd.read_csv(UK_ACCIDENTS_DATA)"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "code",
212
+ "execution_count": null,
213
+ "metadata": {},
214
+ "outputs": [],
215
+ "source": [
216
+ "r.selected_data"
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "code",
221
+ "execution_count": null,
222
+ "metadata": {},
223
+ "outputs": [],
224
+ "source": [
225
+ "r.layers"
226
+ ]
227
+ },
228
+ {
229
+ "cell_type": "code",
230
+ "execution_count": null,
231
+ "metadata": {},
232
+ "outputs": [],
233
+ "source": [
234
+ "r.mapbox_key"
235
+ ]
236
+ },
237
+ {
238
+ "cell_type": "code",
239
+ "execution_count": null,
240
+ "metadata": {},
241
+ "outputs": [],
242
+ "source": [
243
+ "r.to_json()"
244
+ ]
245
+ },
246
+ {
247
+ "cell_type": "code",
248
+ "execution_count": null,
249
+ "metadata": {},
250
+ "outputs": [],
251
+ "source": [
252
+ "r.selected_data"
253
+ ]
254
+ },
255
+ {
256
+ "cell_type": "code",
257
+ "execution_count": null,
258
+ "metadata": {},
259
+ "outputs": [],
260
+ "source": [
261
+ "r.deck_widget.on_"
262
+ ]
263
+ },
264
+ {
265
+ "cell_type": "code",
266
+ "execution_count": 10,
267
+ "metadata": {},
268
+ "outputs": [
269
+ {
270
+ "data": {
271
+ "text/html": [
272
+ "\n",
273
+ " <iframe\n",
274
+ " width=\"100%\"\n",
275
+ " height=500\n",
276
+ " frameborder=\"0\"\n",
277
+ " srcdoc=\"&lt;!DOCTYPE html&gt;\n",
278
+ "&lt;html&gt;\n",
279
+ " &lt;head&gt;\n",
280
+ " &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
281
+ " &lt;title&gt;pydeck&lt;/title&gt;\n",
282
+ " &lt;script src=&quot;https://api.tiles.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js&quot;&gt;&lt;/script&gt;\n",
283
+ " &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot; /&gt;\n",
284
+ " &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot; /&gt;\n",
285
+ " &lt;script src=&#x27;https://cdn.jsdelivr.net/npm/@deck.gl/jupyter-widget@~8.5.*/dist/index.js&#x27;&gt;&lt;/script&gt;\n",
286
+ " &lt;style&gt;\n",
287
+ " body {\n",
288
+ " margin: 0;\n",
289
+ " padding: 0;\n",
290
+ " overflow: hidden;\n",
291
+ "}\n",
292
+ "\n",
293
+ "#deck-map-container {\n",
294
+ " width: 100%;\n",
295
+ " height: 100%;\n",
296
+ " background-color: black;\n",
297
+ "}\n",
298
+ "\n",
299
+ "#map {\n",
300
+ " pointer-events: none;\n",
301
+ " height: 100%;\n",
302
+ " width: 100%;\n",
303
+ " position: absolute;\n",
304
+ " z-index: 1;\n",
305
+ "}\n",
306
+ "\n",
307
+ "#deckgl-overlay {\n",
308
+ " z-index: 2;\n",
309
+ " background: none;\n",
310
+ "}\n",
311
+ "\n",
312
+ "#deck-map-wrapper {\n",
313
+ " width: 100%;\n",
314
+ " height: 100%;\n",
315
+ "}\n",
316
+ "\n",
317
+ "#deck-container {\n",
318
+ " width: 100vw;\n",
319
+ " height: 100vh;\n",
320
+ "}\n",
321
+ " &lt;/style&gt;\n",
322
+ " &lt;/head&gt;\n",
323
+ " &lt;body&gt;\n",
324
+ " &lt;div id=&quot;deck-container&quot;&gt;\n",
325
+ " &lt;/div&gt;\n",
326
+ " &lt;/body&gt;\n",
327
+ " &lt;script&gt;\n",
328
+ " const jsonInput = {&quot;initialViewState&quot;: {&quot;bearing&quot;: 0, &quot;latitude&quot;: 49.254, &quot;longitude&quot;: -123.13, &quot;maxZoom&quot;: 16, &quot;pitch&quot;: 45, &quot;zoom&quot;: 11}, &quot;layers&quot;: [{&quot;@@type&quot;: &quot;PolygonLayer&quot;, &quot;data&quot;: [[[-123.0, 49.196], [-123.0, 49.324], [-123.306, 49.324], [-123.306, 49.196]]], &quot;getFillColor&quot;: [0, 0, 0, 20], &quot;getPolygon&quot;: &quot;@@=-&quot;, &quot;id&quot;: &quot;29119cc5-60a8-496d-9bba-d38c0b2dad8d&quot;, &quot;stroked&quot;: false}, {&quot;@@type&quot;: &quot;GeoJsonLayer&quot;, &quot;data&quot;: &quot;https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json&quot;, &quot;extruded&quot;: true, &quot;filled&quot;: true, &quot;getElevation&quot;: &quot;@@=properties.valuePerSqm / 20&quot;, &quot;getFillColor&quot;: &quot;@@=[255, 255, properties.growth * 255]&quot;, &quot;getLineColor&quot;: [255, 255, 255], &quot;id&quot;: &quot;abbb7efd-2f90-4b1b-87c9-37a34332a2a8&quot;, &quot;opacity&quot;: 0.8, &quot;stroked&quot;: false, &quot;wireframe&quot;: true}], &quot;mapProvider&quot;: &quot;carto&quot;, &quot;mapStyle&quot;: &quot;https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json&quot;, &quot;views&quot;: [{&quot;@@type&quot;: &quot;MapView&quot;, &quot;controller&quot;: true}]};\n",
329
+ " const tooltip = true;\n",
330
+ " const customLibraries = null;\n",
331
+ "\n",
332
+ " const deckInstance = createDeck({\n",
333
+ " mapboxApiKey: &#x27;pk.eyJ1IjoiZ2lzd3FzIiwiYSI6ImNqbWg2YWlpeTA0aGkzdXJ0aWs3YzBta2gifQ.o8KckhuMI8ef8JDIBoqJ3Q&#x27;,\n",
334
+ " container: document.getElementById(&#x27;deck-container&#x27;),\n",
335
+ " jsonInput,\n",
336
+ " tooltip,\n",
337
+ " customLibraries\n",
338
+ " });\n",
339
+ "\n",
340
+ " &lt;/script&gt;\n",
341
+ "&lt;/html&gt;\"\n",
342
+ " ></iframe>\n",
343
+ " "
344
+ ],
345
+ "text/plain": [
346
+ "{\"initialViewState\": {\"bearing\": 0, \"latitude\": 49.254, \"longitude\": -123.13, \"maxZoom\": 16, \"pitch\": 45, \"zoom\": 11}, \"layers\": [{\"@@type\": \"PolygonLayer\", \"data\": [[[-123.0, 49.196], [-123.0, 49.324], [-123.306, 49.324], [-123.306, 49.196]]], \"getFillColor\": [0, 0, 0, 20], \"getPolygon\": \"@@=-\", \"id\": \"29119cc5-60a8-496d-9bba-d38c0b2dad8d\", \"stroked\": false}, {\"@@type\": \"GeoJsonLayer\", \"data\": \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json\", \"extruded\": true, \"filled\": true, \"getElevation\": \"@@=properties.valuePerSqm / 20\", \"getFillColor\": \"@@=[255, 255, properties.growth * 255]\", \"getLineColor\": [255, 255, 255], \"id\": \"abbb7efd-2f90-4b1b-87c9-37a34332a2a8\", \"opacity\": 0.8, \"stroked\": false, \"wireframe\": true}], \"mapProvider\": \"carto\", \"mapStyle\": \"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json\", \"views\": [{\"@@type\": \"MapView\", \"controller\": true}]}"
347
+ ]
348
+ },
349
+ "execution_count": 10,
350
+ "metadata": {},
351
+ "output_type": "execute_result"
352
+ }
353
+ ],
354
+ "source": [
355
+ "import pydeck as pdk\n",
356
+ "\n",
357
+ "DATA_URL = \"https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/geojson/vancouver-blocks.json\"\n",
358
+ "LAND_COVER = [[[-123.0, 49.196], [-123.0, 49.324], [-123.306, 49.324], [-123.306, 49.196]]]\n",
359
+ "\n",
360
+ "INITIAL_VIEW_STATE = pdk.ViewState(latitude=49.254, longitude=-123.13, zoom=11, max_zoom=16, pitch=45, bearing=0)\n",
361
+ "\n",
362
+ "polygon = pdk.Layer(\n",
363
+ " \"PolygonLayer\",\n",
364
+ " LAND_COVER,\n",
365
+ " stroked=False,\n",
366
+ " # processes the data as a flat longitude-latitude pair\n",
367
+ " get_polygon=\"-\",\n",
368
+ " get_fill_color=[0, 0, 0, 20],\n",
369
+ ")\n",
370
+ "\n",
371
+ "geojson = pdk.Layer(\n",
372
+ " \"GeoJsonLayer\",\n",
373
+ " DATA_URL,\n",
374
+ " opacity=0.8,\n",
375
+ " stroked=False,\n",
376
+ " filled=True,\n",
377
+ " extruded=True,\n",
378
+ " wireframe=True,\n",
379
+ " get_elevation=\"properties.valuePerSqm / 20\",\n",
380
+ " get_fill_color=\"[255, 255, properties.growth * 255]\",\n",
381
+ " get_line_color=[255, 255, 255],\n",
382
+ ")\n",
383
+ "\n",
384
+ "r = pdk.Deck(layers=[polygon, geojson], initial_view_state=INITIAL_VIEW_STATE, height=800, width=\"50%\")\n",
385
+ "r"
386
+ ]
387
+ },
388
+ {
389
+ "cell_type": "code",
390
+ "execution_count": null,
391
+ "metadata": {},
392
+ "outputs": [],
393
+ "source": []
394
+ }
395
+ ],
396
+ "metadata": {
397
+ "kernelspec": {
398
+ "display_name": "Python 3",
399
+ "language": "python",
400
+ "name": "python3"
401
+ },
402
+ "language_info": {
403
+ "codemirror_mode": {
404
+ "name": "ipython",
405
+ "version": 3
406
+ },
407
+ "file_extension": ".py",
408
+ "mimetype": "text/x-python",
409
+ "name": "python",
410
+ "nbconvert_exporter": "python",
411
+ "pygments_lexer": "ipython3",
412
+ "version": "3.8.5"
413
+ }
414
+ },
415
+ "nbformat": 4,
416
+ "nbformat_minor": 4
417
+ }