I've been looking at Adding a WMS layer using folium and https://python-visualization.github.io/folium/modules.html.
I managed to get the example in the above link to work in streamlit but not the WMS I'm trying. I've also tried the WMS in qgis and it works.
I realized I need to specify the coordinate system when connecting to the WMS in the below link. From what I can tell both folium and the wms supports EPSG:900913 = EPSG3857(?). However when adding the wms tile layer all i get is my base map. But the WMS isn't showing.
The WMS can be found at https://resource.sgu.se/dokument/produkter/jordarter-25-100000-wms-beskrivning.pdf https://resource.sgu.se/service/wms/130/jordarter-25-100-tusen
import streamlit as st
import folium
import streamlit_folium
map_geo = folium.Map(location=[57.8,14.14], zoom_start=13, width=1200)
try:
folium.raster_layers.WmsTileLayer(url ='https://resource.sgu.se/service/wms/130/jordarter-25-100-tusen',
layers = ['jord:SE.GOV.SGU.JORD.TACKNINGSKARTA.25K'],
transparent = False,
control = True,
fmt="image/png",
name = 'SGU',
attr = 'im seeing this',
overlay = True,
show = True,
CRS = 'EPSG:900913',
version = '1.3.0',
).add_to(map_geo)
folium.LayerControl().add_to(map_geo)
except Exception as e:
st.write(e)
streamlit_folium.st_folium(map_geo)
I think it may be due to the fact that the target URL and the layer designation are different. I just don't know if the called layer is the intended layer or not. I got this https://resource.sgu.se/service/wms/130/jordarter-25-100-tusen and layer from the content of the link provided.
import folium
map_geo = folium.Map(location=[57.8,14.14], zoom_start=10, width=1200)
folium.raster_layers.WmsTileLayer(url ='https://maps3.sgu.se/geoserver/jord/ows?',
layers = 'SE.GOV.SGU.JORD.TACKNINGSKARTA.25K',
transparent = False,
control = True,
fmt="image/png",
name = 'SGU',
attr = 'im seeing this',
overlay = True,
show = True,
CRS = 'EPSG:900913',
version = '1.3.0',
).add_to(map_geo)
folium.LayerControl().add_to(map_geo)
map_geo