geopython-workshop
geopython-workshop copied to clipboard
add Streamlit exercise to Section 7
- add high level description/overview/demo (@krishnaglodha) for further reading.
https://streamlit.io/playground?example=geospatial -> deck has limited wms support, alternative is https://folium.streamlit.app/ based on leaflet, so should have wms etc
Other option would be to load data from wfs via owslib and geopandas, following this https://pythongis.org/part2/chapter-09/nb/01-retrieving-data-from-wfs.html and then connect pydeck to geopandas as https://deckgl.readthedocs.io/en/latest/gallery/geopandas_integration.html; or connect deck directly to a geojson, returned by a ogcapi-features:
import streamlit as st
import pydeck as pdk
import geopandas as gpd
lakes = gpd.read_file("https://demo.pygeoapi.io/master/collections/lakes/items")
centroids = gpd.GeoDataFrame()
centroids["geometry"] = lakes.geometry.centroid
centroids["name"] = lakes.name
st.pydeck_chart(pdk.Deck(
map_style=None,
initial_view_state=pdk.ViewState(
latitude=40,
longitude=-92,
zoom=3,
pitch=50,
),
layers=[
pdk.Layer(
"GeoJsonLayer",
data=lakes,
opacity=0.5,
get_fill_color= [99, 99, 255],
),
pdk.Layer(
"TextLayer",
data=centroids,
get_position="geometry.coordinates",
get_size=16,
get_color=[0, 0, 50],
get_text="name",
)
],
))
st.dataframe(lakes, use_container_width=True, column_config={
"name_alt": st.column_config.LinkColumn()}, column_order=("name","name_alt"))