dnzengou commited on
Commit
d32e3a5
·
1 Parent(s): 1e39985

Upload panel_leafmap.py

Browse files
Files changed (1) hide show
  1. panel_leafmap.py +68 -0
panel_leafmap.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """panel_leafmap.ipynb
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1t6pTDm97iBCYuNDvlpYgin3mf-6f4Kgn
8
+ """
9
+
10
+ !pip install leafmap
11
+
12
+ import leafmap
13
+ import panel as pn
14
+ pn.extension(sizing_mode="stretch_width")
15
+
16
+ def environment():
17
+ try:
18
+ get_ipython()
19
+ return "notebook"
20
+ except:
21
+ return "server"
22
+ environment()
23
+
24
+ layer = pn.widgets.Select(options=["Census_Regions16659", "Census_Regions_Labels31526", "States"], name='layer')
25
+
26
+ def leafmap_viz(layer):
27
+ m = leafmap.Map(center=[30, -90], zoom=4)
28
+ m.add_census_data(wms="Census 2020", layer=layer)
29
+ return m
30
+
31
+ pn.Column(layer, pn.bind(leafmap_viz, layer))
32
+
33
+ template = pn.template.BootstrapTemplate(
34
+ title="Leapmap Panel App",
35
+ sidebar=[layer],
36
+ main=[pn.bind(leafmap_viz, layer)],
37
+ accent_base_color="#88d8b0",
38
+ header_background="#88d8b0",
39
+ )
40
+ #template.show()
41
+ template.servable()
42
+
43
+ """### All in one cell"""
44
+
45
+ #!pip install leafmap
46
+
47
+ import leafmap
48
+ import panel as pn
49
+ pn.extension(sizing_mode="stretch_width")
50
+
51
+ layer = pn.widgets.Select(options=["Census_Regions16659", "Census_Regions_Labels31526", "States"], name='layer')
52
+
53
+ def leafmap_viz(layer):
54
+ m = leafmap.Map(center=[30, -90], zoom=4)
55
+ m.add_census_data(wms="Census 2020", layer=layer)
56
+ return m
57
+
58
+ pn.Column(layer, pn.bind(leafmap_viz, layer))
59
+
60
+ template = pn.template.BootstrapTemplate(
61
+ title="Leapmap Panel App",
62
+ sidebar=[layer],
63
+ main=[pn.bind(leafmap_viz, layer)],
64
+ accent_base_color="#88d8b0",
65
+ header_background="#88d8b0",
66
+ )
67
+ template.servable()
68
+