Skip to content

Commit 42e133d

Browse files
committed
Add timestamped geojson example nb
1 parent 1ac51bd commit 42e133d

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

examples/Plugins.ipynb

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,104 @@
277277
"\n",
278278
"m # Click on the top right button."
279279
]
280+
},
281+
{
282+
"cell_type": "markdown",
283+
"metadata": {},
284+
"source": [
285+
"## Timestamped GeoJSON"
286+
]
287+
},
288+
{
289+
"cell_type": "code",
290+
"execution_count": null,
291+
"metadata": {
292+
"collapsed": false
293+
},
294+
"outputs": [],
295+
"source": [
296+
"from folium import plugins\n",
297+
"\n",
298+
"m = folium.Map(location=[35.68159659061569, 139.76451516151428], zoom_start=16)\n",
299+
"\n",
300+
"lines = [\n",
301+
" {\n",
302+
" \"coordinates\": [\n",
303+
" [139.76451516151428, 35.68159659061569], # Lon, Lat\n",
304+
" [139.75964426994324, 35.682590062684206],\n",
305+
" ],\n",
306+
" \"dates\": [\n",
307+
" \"2017-06-02T00:00:00\",\n",
308+
" \"2017-06-02T00:10:00\"\n",
309+
" ],\n",
310+
" \"color\": \"red\"\n",
311+
" },\n",
312+
" {\n",
313+
" \"coordinates\": [\n",
314+
" [139.75964426994324, 35.682590062684206],\n",
315+
" [139.7575843334198, 35.679505030038506],\n",
316+
" ],\n",
317+
" \"dates\": [\n",
318+
" \"2017-06-02T00:10:00\",\n",
319+
" \"2017-06-02T00:20:00\"\n",
320+
" ],\n",
321+
" \"color\": \"blue\"\n",
322+
" },\n",
323+
" {\n",
324+
" \"coordinates\": [\n",
325+
" [139.7575843334198, 35.679505030038506],\n",
326+
" [139.76337790489197, 35.678040905014065],\n",
327+
" ],\n",
328+
" \"dates\": [\n",
329+
" \"2017-06-02T00:20:00\",\n",
330+
" \"2017-06-02T00:30:00\"\n",
331+
" ],\n",
332+
" \"color\": \"green\",\n",
333+
" \"weight\": 15,\n",
334+
" },\n",
335+
" {\n",
336+
" \"coordinates\": [\n",
337+
" [139.76337790489197, 35.678040905014065],\n",
338+
" [139.76451516151428, 35.68159659061569],\n",
339+
" ],\n",
340+
" \"dates\": [\n",
341+
" \"2017-06-02T00:30:00\",\n",
342+
" \"2017-06-02T00:40:00\"\n",
343+
" ],\n",
344+
" \"color\": \"#FFFFFF\",\n",
345+
" },\n",
346+
" \n",
347+
"]\n",
348+
"\n",
349+
"\n",
350+
"features = [\n",
351+
" {\n",
352+
" \"type\": \"Feature\",\n",
353+
" \"geometry\": {\n",
354+
" \"type\": \"LineString\",\n",
355+
" \"coordinates\": line[\"coordinates\"],\n",
356+
" },\n",
357+
" \"properties\": {\n",
358+
" \"times\": line[\"dates\"],\n",
359+
" \"style\": {\n",
360+
" \"color\": line[\"color\"],\n",
361+
" \"weight\": line[\"weight\"] if \"weight\" in line else 5\n",
362+
" }\n",
363+
" }\n",
364+
" }\n",
365+
"for line in lines]\n",
366+
"\n",
367+
"\n",
368+
"plugins.TimestampedGeoJson({\n",
369+
" \"type\": \"FeatureCollection\",\n",
370+
" \"features\": features,\n",
371+
"}, period=\"PT1M\", add_last_point=True).add_to(m)\n",
372+
"\n",
373+
"\n",
374+
"m.save(os.path.join('results', 'Plugins_5.html'))\n",
375+
"\n",
376+
"m"
377+
]
280378
}
281379
],
282380
"metadata": {

0 commit comments

Comments
 (0)