MultiplexCoopHousingBI_Demo / src /streamlit_app.py
npc0's picture
Update src/streamlit_app.py
2619083 verified
raw
history blame
1.76 kB
import altair as alt
import numpy as np
import pandas as pd
import streamlit as st
"""
# Welcome to Streamlit!
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).
In the meantime, below is an example of what you can do with just a few lines of code:
"""
import streamlit as st
from streamlit_folium import st_folium
from folium.plugins import Draw
import folium
m = folium.Map(location=[40.7128, -74.0060], zoom_start=12)
Draw(export=True).add_to(m)
output = st_folium(m, width=700, height=500)
import pandas as pd
# Login using e.g. `huggingface-cli login` to access this dataset
df = pd.read_parquet("hf://datasets/ProjectMultiplexCoop/PropertyBoundaries/Property_Boundaries_4326.parquet")
color_map = {
"RESERVE": "#00FF00", # Green
"COMMON": "#FF0000", # Red
"CORRIDOR": "#0000FF", # Blue
}
import folium
m = folium.Map(location=[43.6534817, -79.3839347], zoom_start=12)
def style_function(feature):
return {
'fillColor': color_map.get(feature['properties']['type'], "#888888"),
'color': color_map.get(feature['properties']['type'], "#888888"),
'weight': 2,
'fillOpacity': 0.5
}
# For GeoJSON features in a list:
geojson = {"type": "FeatureCollection", "features": features}
folium.GeoJson(
geojson,
style_function=style_function
).add_to(m)
# Or, for a GeoDataFrame:
# folium.GeoJson(
# gdf.to_json(),
# style_function=style_function
# ).add_to(m)
m
# if output and 'last_active_drawing' in output:
# geojson_data = output['last_active_drawing']
# st.write("Geofence drawn:", geojson_data)