Spaces:
Sleeping
Sleeping
Update my_pages/page_school.py
Browse files- my_pages/page_school.py +13 -53
my_pages/page_school.py
CHANGED
|
@@ -1,60 +1,20 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
-
import plotly.graph_objects as go
|
| 4 |
-
from geopy.distance import geodesic
|
| 5 |
-
from utils import load_data, classify_score
|
| 6 |
|
| 7 |
def render():
|
| 8 |
-
st.title("๐ซ ์ด๋ฑํ๊ต ์ฃผ๋ณ
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
for _, row in school_df.iterrows():
|
| 18 |
-
name = row.get("faclt_nm", "ํ๊ต")
|
| 19 |
-
lat_s = row["refine_wgs84_lat"]
|
| 20 |
-
lon_s = row["refine_wgs84_logt"]
|
| 21 |
-
|
| 22 |
-
nearby = [
|
| 23 |
-
(lat, lon, score) for lat, lon, score in safe_points
|
| 24 |
-
if geodesic((lat_s, lon_s), (lat, lon)).meters <= 1000
|
| 25 |
-
]
|
| 26 |
-
nearby = sorted(nearby, key=lambda x: x[2], reverse=True)
|
| 27 |
-
|
| 28 |
-
if nearby:
|
| 29 |
-
lats = [pt[0] for pt in nearby]
|
| 30 |
-
lons = [pt[1] for pt in nearby]
|
| 31 |
-
fig.add_trace(go.Scattermapbox(
|
| 32 |
-
mode="lines+markers",
|
| 33 |
-
lat=lats, lon=lons,
|
| 34 |
-
marker=dict(size=8, color='green'),
|
| 35 |
-
line=dict(width=2, color='green'),
|
| 36 |
-
name=f"{name} ์ฃผ๋ณ",
|
| 37 |
-
hoverinfo="text",
|
| 38 |
-
text=[f"{name}<br>์ ์: {s}" for (_, _, s) in nearby]
|
| 39 |
-
))
|
| 40 |
-
|
| 41 |
-
fig.add_trace(go.Scattermapbox(
|
| 42 |
-
mode="markers+text",
|
| 43 |
-
lat=[lat_s], lon=[lon_s],
|
| 44 |
-
marker=dict(size=12, color='blue'),
|
| 45 |
-
text=[name],
|
| 46 |
-
textposition="top center",
|
| 47 |
-
name=f"{name} ์์น"
|
| 48 |
-
))
|
| 49 |
-
|
| 50 |
-
fig.update_layout(
|
| 51 |
-
mapbox=dict(
|
| 52 |
-
style="carto-positron",
|
| 53 |
-
center=dict(lat=37.198, lon=127.034),
|
| 54 |
-
zoom=11
|
| 55 |
-
),
|
| 56 |
-
title="ํ์ฑ์ ์ด๋ฑํ๊ต ์ฃผ๋ณ ์์ ๊ฒฝ๋ก",
|
| 57 |
-
margin=dict(l=0, r=0, t=40, b=0)
|
| 58 |
-
)
|
| 59 |
-
|
| 60 |
-
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import folium
|
| 3 |
+
from streamlit_folium import st_folium
|
| 4 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def render():
|
| 7 |
+
st.title("๐ซ ์ด๋ฑํ๊ต ์ฃผ๋ณ ๊ฒฝ๋ก")
|
| 8 |
|
| 9 |
+
df = pd.read_excel("data/์ด๋ฑํ๊ต.xlsx", engine="openpyxl")
|
| 10 |
+
df = df.dropna(subset=["refine_wgs84_lat", "refine_wgs84_logt"])
|
| 11 |
|
| 12 |
+
m = folium.Map(location=[37.2, 127.0], zoom_start=11)
|
| 13 |
+
for _, row in df.iterrows():
|
| 14 |
+
folium.Marker(
|
| 15 |
+
location=[row["refine_wgs84_lat"], row["refine_wgs84_logt"]],
|
| 16 |
+
popup=row.get("ํ๊ต๋ช
", "์ด๋ฑํ๊ต"),
|
| 17 |
+
icon=folium.Icon(color="blue", icon="info-sign")
|
| 18 |
+
).add_to(m)
|
| 19 |
|
| 20 |
+
st_folium(m, width=1000, height=700)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|