Spaces:
Sleeping
Sleeping
Commit
·
0026eb1
1
Parent(s):
7a0165b
modify pages
Browse files
pages/1_🌲_Japan_Vegetation_Cover.py
CHANGED
@@ -2,9 +2,7 @@ import streamlit as st
|
|
2 |
import geopandas as gpd
|
3 |
import pydeck as pdk
|
4 |
import pandas as pd
|
5 |
-
import
|
6 |
-
import matplotlib.colors as mcolors
|
7 |
-
import numpy as np
|
8 |
import pathlib
|
9 |
import os
|
10 |
import requests
|
@@ -23,7 +21,7 @@ st.sidebar.info(
|
|
23 |
st.sidebar.title("Contact")
|
24 |
st.sidebar.info(
|
25 |
"""
|
26 |
-
|
27 |
"""
|
28 |
)
|
29 |
|
@@ -77,7 +75,7 @@ def app():
|
|
77 |
st.title("Japan Vegetation Cover Fraction")
|
78 |
st.markdown(
|
79 |
"""**Introduction:** This interactive dashboard is designed for visualizing Japan Fractional Vegetation Cover at town block levels.
|
80 |
-
The data sources include [Vegetation Cover Fraction](https://zenodo.org/records/5553516) from a
|
81 |
and [Cartographic Boundary Files](https://www.e-stat.go.jp/gis/statmap-search?page=1&type=2&aggregateUnitForBoundary=A&toukeiCode=00200521&toukeiYear=2015&serveyId=A002005212015&coordsys=1&format=shape&datum=2000) from Census of Japan 2015.
|
82 |
"""
|
83 |
)
|
@@ -115,14 +113,9 @@ def app():
|
|
115 |
else:
|
116 |
elev_scale = 1
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
def get_color(value):
|
122 |
-
rgba = cmap(norm(value))
|
123 |
-
return [int(rgba[0]*255), int(rgba[1]*255), int(rgba[2]*255)]
|
124 |
-
|
125 |
-
gdf['color'] = gdf[selected_attribute].apply(get_color)
|
126 |
|
127 |
gdf_null = select_null(gdf, selected_attribute)
|
128 |
gdf = select_non_null(gdf, selected_attribute)
|
@@ -178,12 +171,7 @@ def app():
|
|
178 |
|
179 |
st.pydeck_chart(r)
|
180 |
|
181 |
-
|
182 |
-
fig, ax = plt.subplots(figsize=(6, 1))
|
183 |
-
fig.subplots_adjust(bottom=0.5)
|
184 |
-
cbar = fig.colorbar(plt.cm.ScalarMappable(norm=norm, cmap=cmap), cax=ax, orientation='horizontal')
|
185 |
-
cbar.set_label(selected_attribute)
|
186 |
-
st.pyplot(fig)
|
187 |
|
188 |
if st.checkbox("Show raw data"):
|
189 |
st.write(gdf[[selected_attribute, 'NAME']])
|
|
|
2 |
import geopandas as gpd
|
3 |
import pydeck as pdk
|
4 |
import pandas as pd
|
5 |
+
from branca import colormap as cm
|
|
|
|
|
6 |
import pathlib
|
7 |
import os
|
8 |
import requests
|
|
|
21 |
st.sidebar.title("Contact")
|
22 |
st.sidebar.info(
|
23 |
"""
|
24 |
+
Qiusheng Wu at [wetlands.io](https://wetlands.io) | [GitHub](https://github.com/giswqs) | [Twitter](https://twitter.com/giswqs) | [YouTube](https://www.youtube.com/c/QiushengWu) | [LinkedIn](https://www.linkedin.com/in/qiushengwu)
|
25 |
"""
|
26 |
)
|
27 |
|
|
|
75 |
st.title("Japan Vegetation Cover Fraction")
|
76 |
st.markdown(
|
77 |
"""**Introduction:** This interactive dashboard is designed for visualizing Japan Fractional Vegetation Cover at town block levels.
|
78 |
+
The data sources include [Vegetation Cover Fraction](https://zenodo.org/records/5553516) from a research project (https://doi.org/10.3130/aijt.28.521),
|
79 |
and [Cartographic Boundary Files](https://www.e-stat.go.jp/gis/statmap-search?page=1&type=2&aggregateUnitForBoundary=A&toukeiCode=00200521&toukeiYear=2015&serveyId=A002005212015&coordsys=1&format=shape&datum=2000) from Census of Japan 2015.
|
80 |
"""
|
81 |
)
|
|
|
113 |
else:
|
114 |
elev_scale = 1
|
115 |
|
116 |
+
color_scale = cm.LinearColormap(colors=palette, vmin=gdf[selected_attribute].min(), vmax=gdf[selected_attribute].max(), n=n_colors)
|
117 |
+
gdf['color'] = gdf[selected_attribute].apply(lambda x: color_scale(x))
|
118 |
+
gdf['color'] = gdf['color'].apply(lambda x: [int(x[1:3], 16), int(x[3:5], 16), int(x[5:7], 16)])
|
|
|
|
|
|
|
|
|
|
|
119 |
|
120 |
gdf_null = select_null(gdf, selected_attribute)
|
121 |
gdf = select_non_null(gdf, selected_attribute)
|
|
|
171 |
|
172 |
st.pydeck_chart(r)
|
173 |
|
174 |
+
st.write(color_scale)
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
if st.checkbox("Show raw data"):
|
177 |
st.write(gdf[[selected_attribute, 'NAME']])
|