Spaces:
Running
Running
tweak
Browse files
app.py
CHANGED
@@ -11,103 +11,156 @@
|
|
11 |
# See the License for the specific language governing permissions and
|
12 |
# limitations under the License.
|
13 |
|
14 |
-
# +
|
15 |
import leafmap.foliumap as leafmap
|
16 |
import streamlit as st
|
|
|
17 |
|
|
|
18 |
public = "https://minio.carlboettiger.info/shared-data/pad/public.pmtiles"
|
19 |
tribal = "https://minio.carlboettiger.info/shared-data/pad/tribal.pmtiles"
|
20 |
private = "https://minio.carlboettiger.info/shared-data/pad/private.pmtiles"
|
21 |
mixed = "https://minio.carlboettiger.info/shared-data/pad/mixed.pmtiles"
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
23 |
"version": 8,
|
24 |
"sources": {
|
25 |
"public": {
|
26 |
"type": "vector",
|
27 |
"url": "pmtiles://" + public,
|
28 |
-
"attribution": "
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
"tribal": {
|
31 |
"type": "vector",
|
32 |
"url": "pmtiles://" + tribal,
|
33 |
-
"attribution": "
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
"private": {
|
36 |
"type": "vector",
|
37 |
"url": "pmtiles://" + private,
|
38 |
-
"attribution": "PMTiles",
|
39 |
-
},
|
40 |
"mixed": {
|
41 |
"type": "vector",
|
42 |
"url": "pmtiles://" + mixed,
|
43 |
-
"attribution": "PMTiles",
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
{
|
48 |
"id": "tribal",
|
49 |
"source": "tribal",
|
50 |
"source-layer": "tribal_protected",
|
51 |
"type": "fill",
|
52 |
-
"paint": {"fill-color":
|
53 |
},
|
54 |
{
|
55 |
"id": "public",
|
56 |
"source": "public",
|
57 |
"source-layer": "public_protected",
|
58 |
"type": "fill",
|
59 |
-
"paint": {"fill-color":
|
60 |
},
|
61 |
{
|
62 |
"id": "private",
|
63 |
"source": "private",
|
64 |
"source-layer": "private_protected",
|
65 |
"type": "fill",
|
66 |
-
"paint": {"fill-color":
|
67 |
-
},
|
68 |
-
{
|
69 |
-
"id": "mixed",
|
70 |
-
"source": "mixed",
|
71 |
-
"source-layer": "mixed_protected",
|
72 |
-
"type": "fill",
|
73 |
-
"paint": {"fill-color": "#005a00", "fill-opacity": 0.5}
|
74 |
-
}
|
75 |
-
]
|
76 |
-
}
|
77 |
-
|
78 |
-
# -
|
79 |
-
|
80 |
-
st.set_page_config(layout="wide", page_title="Protected Areas Explorer", page_icon=":globe:")
|
81 |
-
|
82 |
|
83 |
# +
|
84 |
-
|
85 |
-
|
86 |
-
m = leafmap.Map(center=[35, -100], zoom=4)
|
87 |
-
SURFACE_IMAGE ="https://huggingface.co/spaces/boettiger-lab/protected-areas/resolve/main/mobi/{z}/{x}/{y}.png"
|
88 |
m.add_basemap("CartoDB.DarkMatter")
|
|
|
89 |
m.add_tile_layer(
|
90 |
-
url=
|
91 |
-
name="
|
92 |
attribution="NatureServe",
|
93 |
opacity=0.99
|
94 |
)
|
95 |
-
m.add_pmtiles(
|
96 |
-
tribal, name="Protected Areas", style=style, overlay=True, show=True, zoom_to_layer=False
|
97 |
-
)
|
98 |
|
99 |
-
m.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
|
102 |
# +
|
|
|
|
|
103 |
|
104 |
# style = leafmap.pmtiles_style(url) # Use default style
|
105 |
|
106 |
m = leafmap.Map(center=[35, -100], zoom=4)
|
107 |
-
SURFACE_IMAGE ="https://minio.carlboettiger.info/shared-data/mobi-tiles/red/{z}/{x}/{y}.png"
|
108 |
m.add_basemap("Esri.WorldGrayCanvas")
|
109 |
m.add_tile_layer(
|
110 |
-
url=
|
111 |
name="MOBI",
|
112 |
attribution="NatureServe",
|
113 |
opacity=0.9
|
@@ -116,4 +169,4 @@ m.add_pmtiles(
|
|
116 |
tribal, name="PMTiles", style=style, overlay=True, show=True, zoom_to_layer=False
|
117 |
)
|
118 |
|
119 |
-
m.to_streamlit()
|
|
|
11 |
# See the License for the specific language governing permissions and
|
12 |
# limitations under the License.
|
13 |
|
|
|
14 |
import leafmap.foliumap as leafmap
|
15 |
import streamlit as st
|
16 |
+
st.set_page_config(layout="wide", page_title="Protected Areas Explorer", page_icon=":globe:")
|
17 |
|
18 |
+
# +
|
19 |
public = "https://minio.carlboettiger.info/shared-data/pad/public.pmtiles"
|
20 |
tribal = "https://minio.carlboettiger.info/shared-data/pad/tribal.pmtiles"
|
21 |
private = "https://minio.carlboettiger.info/shared-data/pad/private.pmtiles"
|
22 |
mixed = "https://minio.carlboettiger.info/shared-data/pad/mixed.pmtiles"
|
23 |
+
red = "#850101"
|
24 |
+
purple = "#BF40BF"
|
25 |
+
green = "#005a00"
|
26 |
+
blue = "#3388ff"
|
27 |
+
|
28 |
+
public_style = {
|
29 |
"version": 8,
|
30 |
"sources": {
|
31 |
"public": {
|
32 |
"type": "vector",
|
33 |
"url": "pmtiles://" + public,
|
34 |
+
"attribution": "US PAD v3"}},
|
35 |
+
"layers": [{
|
36 |
+
"id": "public",
|
37 |
+
"source": "public",
|
38 |
+
"source-layer": "public_protected",
|
39 |
+
"type": "fill",
|
40 |
+
"paint": {"fill-color": blue, "fill-opacity": 0.5}}]}
|
41 |
+
private_style = {
|
42 |
+
"version": 8,
|
43 |
+
"sources": {
|
44 |
+
"private": {
|
45 |
+
"type": "vector",
|
46 |
+
"url": "pmtiles://" + private,
|
47 |
+
"attribution": "US PAD v3",}},
|
48 |
+
"layers": [
|
49 |
+
{
|
50 |
+
"id": "private",
|
51 |
+
"source": "private",
|
52 |
+
"source-layer": "private_protected",
|
53 |
+
"type": "fill",
|
54 |
+
"paint": {"fill-color": red, "fill-opacity": 0.5}}]}
|
55 |
+
tribal_style = {
|
56 |
+
"version": 8,
|
57 |
+
"sources": {
|
58 |
"tribal": {
|
59 |
"type": "vector",
|
60 |
"url": "pmtiles://" + tribal,
|
61 |
+
"attribution": "US PAD v3"}},
|
62 |
+
"layers": [{
|
63 |
+
"id": "tribal",
|
64 |
+
"source": "tribal",
|
65 |
+
"source-layer": "tribal_protected",
|
66 |
+
"type": "fill",
|
67 |
+
"paint": {"fill-color": purple, "fill-opacity": 0.6}}]}
|
68 |
+
|
69 |
+
mixed_style = {
|
70 |
+
"version": 8,
|
71 |
+
"sources": {
|
72 |
+
"mixed": {
|
73 |
+
"type": "vector",
|
74 |
+
"url": "pmtiles://" + mixed,
|
75 |
+
"attribution": "US PAD v3"}},
|
76 |
+
"layers": [{
|
77 |
+
"id": "mixed",
|
78 |
+
"source": "mixed",
|
79 |
+
"source-layer": "mixed_protected",
|
80 |
+
"type": "fill",
|
81 |
+
"paint": {"fill-color": green, "fill-opacity": 0.6}}]}
|
82 |
+
|
83 |
+
# -
|
84 |
+
|
85 |
+
## Tooltip layer -- hack
|
86 |
+
combined_style = {
|
87 |
+
"version": 8,
|
88 |
+
"sources": {
|
89 |
+
"public": {
|
90 |
+
"type": "vector",
|
91 |
+
"url": "pmtiles://" + public,
|
92 |
+
"attribution": "PMTiles"},
|
93 |
+
"tribal": {
|
94 |
+
"type": "vector",
|
95 |
+
"url": "pmtiles://" + tribal,
|
96 |
+
"attribution": "PMTiles"},
|
97 |
"private": {
|
98 |
"type": "vector",
|
99 |
"url": "pmtiles://" + private,
|
100 |
+
"attribution": "PMTiles"},
|
|
|
101 |
"mixed": {
|
102 |
"type": "vector",
|
103 |
"url": "pmtiles://" + mixed,
|
104 |
+
"attribution": "PMTiles"}},
|
105 |
+
"layers": [{
|
106 |
+
"id": "mixed",
|
107 |
+
"source": "mixed",
|
108 |
+
"source-layer": "mixed_protected",
|
109 |
+
"type": "fill",
|
110 |
+
"paint": {"fill-color": green, "fill-opacity": 0.}},
|
111 |
{
|
112 |
"id": "tribal",
|
113 |
"source": "tribal",
|
114 |
"source-layer": "tribal_protected",
|
115 |
"type": "fill",
|
116 |
+
"paint": {"fill-color": purple, "fill-opacity": 0.}
|
117 |
},
|
118 |
{
|
119 |
"id": "public",
|
120 |
"source": "public",
|
121 |
"source-layer": "public_protected",
|
122 |
"type": "fill",
|
123 |
+
"paint": {"fill-color": blue, "fill-opacity": 0.}
|
124 |
},
|
125 |
{
|
126 |
"id": "private",
|
127 |
"source": "private",
|
128 |
"source-layer": "private_protected",
|
129 |
"type": "fill",
|
130 |
+
"paint": {"fill-color": red, "fill-opacity": 0.}}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
# +
|
133 |
+
m = leafmap.Map(center=[35, -100], zoom=3)
|
|
|
|
|
|
|
134 |
m.add_basemap("CartoDB.DarkMatter")
|
135 |
+
|
136 |
m.add_tile_layer(
|
137 |
+
url="https://minio.carlboettiger.info/shared-data/mobi-tiles/grey/{z}/{x}/{y}.png",
|
138 |
+
name="Imperiled Species Richness (Greyscale)",
|
139 |
attribution="NatureServe",
|
140 |
opacity=0.99
|
141 |
)
|
|
|
|
|
|
|
142 |
|
143 |
+
m.add_pmtiles( public, name="Public", style=public_style, overlay=True, show=True, zoom_to_layer=False)
|
144 |
+
m.add_pmtiles(private, name="Private", style=private_style, overlay=True, show=True, zoom_to_layer=False)
|
145 |
+
m.add_pmtiles(tribal, name="Tribal", style=tribal_style, overlay=True, show=True, zoom_to_layer=False)
|
146 |
+
m.add_pmtiles(mixed, name="Mixed", style=mixed_style, overlay=True, show=True, zoom_to_layer=False)
|
147 |
+
m.add_pmtiles(tribal, name="tooltip", style=combined_style, overlay=True, show=True, zoom_to_layer=False)
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
m.to_streamlit(height=900)
|
152 |
|
153 |
|
154 |
# +
|
155 |
+
st.write("# MOBI Species Richness (Light theme)")
|
156 |
+
|
157 |
|
158 |
# style = leafmap.pmtiles_style(url) # Use default style
|
159 |
|
160 |
m = leafmap.Map(center=[35, -100], zoom=4)
|
|
|
161 |
m.add_basemap("Esri.WorldGrayCanvas")
|
162 |
m.add_tile_layer(
|
163 |
+
url="https://minio.carlboettiger.info/shared-data/mobi-tiles/red/{z}/{x}/{y}.png",
|
164 |
name="MOBI",
|
165 |
attribution="NatureServe",
|
166 |
opacity=0.9
|
|
|
169 |
tribal, name="PMTiles", style=style, overlay=True, show=True, zoom_to_layer=False
|
170 |
)
|
171 |
|
172 |
+
m.to_streamlit(height=900)
|