Spaces:
Sleeping
Sleeping
Commit
·
eae2075
1
Parent(s):
ec901bf
modify pages
Browse files
pages/1_🌲_Japan_Vegetation_Cover.py
CHANGED
@@ -38,6 +38,9 @@ data_links = {
|
|
38 |
"Saitama": "https://raw.githubusercontent.com/kunifujiwara/data/master/frac_veg/FRAC_VEG_Saitama.geojson",
|
39 |
}
|
40 |
|
|
|
|
|
|
|
41 |
@st.cache_data
|
42 |
def get_geom_data(prefecture):
|
43 |
response = requests.get(data_links[prefecture])
|
@@ -92,9 +95,8 @@ def app():
|
|
92 |
[0.6, 0.68, 0.7, 0.7, 1.5, 0.8]
|
93 |
)
|
94 |
|
95 |
-
palettes = cm.list_colormaps()
|
96 |
with row2_col1:
|
97 |
-
palette = st.selectbox("Color palette",
|
98 |
with row2_col2:
|
99 |
n_colors = st.slider("Number of colors", min_value=2, max_value=20, value=8)
|
100 |
with row2_col3:
|
@@ -111,7 +113,7 @@ def app():
|
|
111 |
else:
|
112 |
elev_scale = 1
|
113 |
|
114 |
-
color_scale = cm.LinearColormap(colors=
|
115 |
gdf['color'] = gdf[selected_attribute].apply(lambda x: color_scale(x))
|
116 |
gdf['color'] = gdf['color'].apply(lambda x: [int(x[1:3], 16), int(x[3:5], 16), int(x[5:7], 16)])
|
117 |
|
|
|
38 |
"Saitama": "https://raw.githubusercontent.com/kunifujiwara/data/master/frac_veg/FRAC_VEG_Saitama.geojson",
|
39 |
}
|
40 |
|
41 |
+
# Predefined list of color palettes
|
42 |
+
color_palettes = ['viridis', 'plasma', 'inferno', 'magma', 'cividis', 'Blues', 'Greens', 'Reds', 'Oranges', 'Purples']
|
43 |
+
|
44 |
@st.cache_data
|
45 |
def get_geom_data(prefecture):
|
46 |
response = requests.get(data_links[prefecture])
|
|
|
95 |
[0.6, 0.68, 0.7, 0.7, 1.5, 0.8]
|
96 |
)
|
97 |
|
|
|
98 |
with row2_col1:
|
99 |
+
palette = st.selectbox("Color palette", color_palettes, index=color_palettes.index('Blues'))
|
100 |
with row2_col2:
|
101 |
n_colors = st.slider("Number of colors", min_value=2, max_value=20, value=8)
|
102 |
with row2_col3:
|
|
|
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 |
|