Spaces:
Sleeping
Sleeping
hide other controls
Browse files- .streamlit/config.toml +2 -0
- Final_IITGN-Logo-symmetric-Color.png +0 -0
- IFS.jpg +0 -0
- app.py +42 -7
.streamlit/config.toml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
backgroundColor="#FFFFFF"
|
Final_IITGN-Logo-symmetric-Color.png
ADDED
![]() |
IFS.jpg
ADDED
![]() |
app.py
CHANGED
@@ -8,12 +8,30 @@ import leafmap.foliumap as leafmap
|
|
8 |
# wide streamlit display
|
9 |
st.set_page_config(layout="wide")
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
file_url = st.query_params.get("file_url", None)
|
12 |
print(f"{file_url=}")
|
13 |
|
14 |
if file_url:
|
15 |
if ("file_url" in st.session_state) and (st.session_state.file_url == file_url):
|
16 |
-
st.toast("Using cached data")
|
17 |
input_gdf = st.session_state.input_gdf
|
18 |
else:
|
19 |
st.session_state.file_url = file_url
|
@@ -24,19 +42,36 @@ if file_url:
|
|
24 |
input_gdf = gpd.read_file(file_url)
|
25 |
input_gdf = input_gdf.to_crs(epsg=7761) # Gujarat zone
|
26 |
st.session_state.input_gdf = input_gdf
|
27 |
-
st.toast("Data loaded and cached")
|
28 |
|
29 |
def format_fn(x):
|
30 |
return input_gdf.drop(columns=["geometry"]).loc[x].to_dict()
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
geometry_gdf = input_gdf[input_gdf.index == input_geometry_idx]
|
34 |
|
35 |
m = leafmap.Map()
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
)
|
|
|
40 |
if map_type == "Google Hybrid Map (displays place names)":
|
41 |
st.write(
|
42 |
"<h4><div style='text-align: center;'>Google Hybrid (displays place names)</div></h4>",
|
@@ -61,7 +96,7 @@ if file_url:
|
|
61 |
zoom_to_layer=True,
|
62 |
style_function=lambda x: {"color": "red", "fillOpacity": 0.0},
|
63 |
)
|
64 |
-
m.to_streamlit()
|
65 |
|
66 |
# Metrics
|
67 |
stats_df = pd.DataFrame()
|
|
|
8 |
# wide streamlit display
|
9 |
st.set_page_config(layout="wide")
|
10 |
|
11 |
+
|
12 |
+
# Logo
|
13 |
+
cols = st.columns([1, 7, 1])
|
14 |
+
with cols[0]:
|
15 |
+
st.image("Final_IITGN-Logo-symmetric-Color.png")
|
16 |
+
with cols[-1]:
|
17 |
+
st.image("IFS.jpg")
|
18 |
+
|
19 |
+
# Title
|
20 |
+
# make title in center
|
21 |
+
with cols[1]:
|
22 |
+
st.markdown(
|
23 |
+
f"""
|
24 |
+
<h1 style="text-align: center;">Bhuvan (भुवन): Interactive KML/GeoJSON Viewer</h1>
|
25 |
+
""",
|
26 |
+
unsafe_allow_html=True,
|
27 |
+
)
|
28 |
+
|
29 |
file_url = st.query_params.get("file_url", None)
|
30 |
print(f"{file_url=}")
|
31 |
|
32 |
if file_url:
|
33 |
if ("file_url" in st.session_state) and (st.session_state.file_url == file_url):
|
34 |
+
# st.toast("Using cached data")
|
35 |
input_gdf = st.session_state.input_gdf
|
36 |
else:
|
37 |
st.session_state.file_url = file_url
|
|
|
42 |
input_gdf = gpd.read_file(file_url)
|
43 |
input_gdf = input_gdf.to_crs(epsg=7761) # Gujarat zone
|
44 |
st.session_state.input_gdf = input_gdf
|
45 |
+
# st.toast("Data loaded and cached")
|
46 |
|
47 |
def format_fn(x):
|
48 |
return input_gdf.drop(columns=["geometry"]).loc[x].to_dict()
|
49 |
|
50 |
+
with st.expander("Advanced Controls", expanded=False):
|
51 |
+
input_geometry_idx = st.selectbox("Select the geometry", input_gdf.index, format_func=format_fn)
|
52 |
+
map_type = st.radio(
|
53 |
+
"",
|
54 |
+
["Esri Satellite Map", "Google Hybrid Map (displays place names)", "Google Satellite Map"],
|
55 |
+
horizontal=True,
|
56 |
+
)
|
57 |
+
height = st.number_input("Map height (px)", 1, 10000, 600, 1)
|
58 |
+
|
59 |
geometry_gdf = input_gdf[input_gdf.index == input_geometry_idx]
|
60 |
|
61 |
m = leafmap.Map()
|
62 |
+
|
63 |
+
st.markdown(
|
64 |
+
"""
|
65 |
+
<style>
|
66 |
+
.stRadio [role=radiogroup]{
|
67 |
+
align-items: center;
|
68 |
+
justify-content: center;
|
69 |
+
}
|
70 |
+
</style>
|
71 |
+
""",
|
72 |
+
unsafe_allow_html=True,
|
73 |
)
|
74 |
+
|
75 |
if map_type == "Google Hybrid Map (displays place names)":
|
76 |
st.write(
|
77 |
"<h4><div style='text-align: center;'>Google Hybrid (displays place names)</div></h4>",
|
|
|
96 |
zoom_to_layer=True,
|
97 |
style_function=lambda x: {"color": "red", "fillOpacity": 0.0},
|
98 |
)
|
99 |
+
m.to_streamlit(height=height)
|
100 |
|
101 |
# Metrics
|
102 |
stats_df = pd.DataFrame()
|