File size: 1,755 Bytes
c007f3b 10d0bac c007f3b 10d0bac c007f3b 2619083 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
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)
|