Skip to content

Commit 18d6223

Browse files
author
ni1o1
committed
add tutorial
1 parent 3010149 commit 18d6223

File tree

3 files changed

+88
-22
lines changed

3 files changed

+88
-22
lines changed

pydeck-getstart.ipynb

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@
8989
},
9090
{
9191
"cell_type": "code",
92-
"execution_count": 83,
92+
"execution_count": 2,
9393
"metadata": {
9494
"ExecuteTime": {
95-
"end_time": "2020-05-30T09:20:39.522179Z",
96-
"start_time": "2020-05-30T09:20:39.516197Z"
95+
"end_time": "2020-05-31T01:32:26.355475Z",
96+
"start_time": "2020-05-31T01:32:25.344173Z"
9797
}
9898
},
9999
"outputs": [],
@@ -108,11 +108,11 @@
108108
},
109109
{
110110
"cell_type": "code",
111-
"execution_count": 2,
111+
"execution_count": 20,
112112
"metadata": {
113113
"ExecuteTime": {
114-
"end_time": "2020-05-30T03:30:03.247530Z",
115-
"start_time": "2020-05-30T03:30:02.570314Z"
114+
"end_time": "2020-05-31T02:06:20.732514Z",
115+
"start_time": "2020-05-31T02:06:20.119127Z"
116116
}
117117
},
118118
"outputs": [
@@ -217,7 +217,7 @@
217217
"4 01:08:17 "
218218
]
219219
},
220-
"execution_count": 2,
220+
"execution_count": 20,
221221
"metadata": {},
222222
"output_type": "execute_result"
223223
}
@@ -232,11 +232,11 @@
232232
},
233233
{
234234
"cell_type": "code",
235-
"execution_count": 84,
235+
"execution_count": 21,
236236
"metadata": {
237237
"ExecuteTime": {
238-
"end_time": "2020-05-30T09:21:31.749810Z",
239-
"start_time": "2020-05-30T09:21:31.741829Z"
238+
"end_time": "2020-05-31T02:06:21.250130Z",
239+
"start_time": "2020-05-31T02:06:21.243120Z"
240240
}
241241
},
242242
"outputs": [
@@ -246,7 +246,7 @@
246246
"464718"
247247
]
248248
},
249-
"execution_count": 84,
249+
"execution_count": 21,
250250
"metadata": {},
251251
"output_type": "execute_result"
252252
}
@@ -260,31 +260,31 @@
260260
"metadata": {},
261261
"source": [
262262
"如果我们直接可视化46万条数据,pydeck还是一下子没法处理那么多,亲测几万条数据还是可以的,但是上十万就会卡死不显示。 \n",
263-
"所以这里还是对数据的经纬度保留三位小数集计后再进行可视化"
263+
"所以这里还是对数据的经纬度保留小数集计后再进行可视化"
264264
]
265265
},
266266
{
267267
"cell_type": "code",
268-
"execution_count": 47,
268+
"execution_count": 22,
269269
"metadata": {
270270
"ExecuteTime": {
271-
"end_time": "2020-05-30T04:05:28.163456Z",
272-
"start_time": "2020-05-30T04:05:28.085635Z"
271+
"end_time": "2020-05-31T02:06:22.229719Z",
272+
"start_time": "2020-05-31T02:06:22.159665Z"
273273
}
274274
},
275275
"outputs": [],
276276
"source": [
277-
"TaxiOD['SLng'] = TaxiOD['SLng'].round(3)\n",
278-
"TaxiOD['SLat'] = TaxiOD['SLat'].round(3)"
277+
"TaxiOD['SLng'] = TaxiOD['SLng'].round(4)\n",
278+
"TaxiOD['SLat'] = TaxiOD['SLat'].round(4)"
279279
]
280280
},
281281
{
282282
"cell_type": "code",
283-
"execution_count": 48,
283+
"execution_count": 23,
284284
"metadata": {
285285
"ExecuteTime": {
286-
"end_time": "2020-05-30T04:05:29.667001Z",
287-
"start_time": "2020-05-30T04:05:29.591207Z"
286+
"end_time": "2020-05-31T02:06:23.212117Z",
287+
"start_time": "2020-05-31T02:06:23.067235Z"
288288
}
289289
},
290290
"outputs": [],
@@ -319,8 +319,8 @@
319319
"execution_count": null,
320320
"metadata": {
321321
"ExecuteTime": {
322-
"end_time": "2020-05-30T09:34:10.238408Z",
323-
"start_time": "2020-05-30T09:34:09.942677Z"
322+
"end_time": "2020-05-31T01:32:35.556882Z",
323+
"start_time": "2020-05-31T01:32:35.331450Z"
324324
}
325325
},
326326
"outputs": [],
@@ -424,6 +424,72 @@
424424
"source": [
425425
"<img src=\"https://gitee.com/ni1o1/pygeo-tutorial/raw/master/resource/deckheatmap.png\" style=\"width:1000px\">"
426426
]
427+
},
428+
{
429+
"cell_type": "markdown",
430+
"metadata": {},
431+
"source": [
432+
"## ScreenGridLayer"
433+
]
434+
},
435+
{
436+
"cell_type": "code",
437+
"execution_count": null,
438+
"metadata": {
439+
"ExecuteTime": {
440+
"end_time": "2020-05-31T02:13:06.311971Z",
441+
"start_time": "2020-05-31T02:13:04.559616Z"
442+
}
443+
},
444+
"outputs": [],
445+
"source": [
446+
"\n",
447+
"import pydeck \n",
448+
"# Define a layer to display on a map\n",
449+
"layer = pydeck.Layer(\n",
450+
" 'ScreenGridLayer',\n",
451+
" Taxi_O_agg, #数据在此输入\n",
452+
" get_position=['SLng', 'SLat'], #指定经纬度的列\n",
453+
" getWeight = 'VehicleNum', #指定权重\n",
454+
" opacity = 1,\n",
455+
" cellSizePixels = 10,\n",
456+
" colorRange = [\n",
457+
" [255,255,204,25],\n",
458+
" [199,233,180,85],\n",
459+
" [127,205,187,127],\n",
460+
" [65,182,196,170],\n",
461+
" [44,127,184,190],\n",
462+
" [37,52,148,255]\n",
463+
" ],\n",
464+
" )\n",
465+
"\n",
466+
"# Set the viewport location\n",
467+
"view_state = pdk.ViewState(\n",
468+
" longitude=114.027465,\n",
469+
" latitude=22.632468,\n",
470+
" zoom=10,\n",
471+
" min_zoom=5,\n",
472+
" max_zoom=16,\n",
473+
" pitch=40,\n",
474+
" bearing=-10)\n",
475+
"\n",
476+
"# Render\n",
477+
"r = pdk.Deck(layers=[layer], \n",
478+
" initial_view_state=view_state,\n",
479+
" mapbox_key = mapbox_key,\n",
480+
" map_style = 'mapbox://styles/mapbox/dark-v9'\n",
481+
" )\n",
482+
"r.show()"
483+
]
484+
},
485+
{
486+
"cell_type": "markdown",
487+
"metadata": {},
488+
"source": [
489+
"<img src=\"https://gitee.com/ni1o1/pygeo-tutorial/raw/master/resource/pydeckgrid.png\" style=\"width:1000px\">\n",
490+
"放大了也能看得比较清楚 \n",
491+
"<img src=\"https://gitee.com/ni1o1/pygeo-tutorial/raw/master/resource/pydeckgrid2.png\" style=\"width:1000px\">"
492+
]
427493
}
428494
],
429495
"metadata": {

resource/pydeckgrid.png

493 KB
Loading

resource/pydeckgrid2.png

292 KB
Loading

0 commit comments

Comments
 (0)