giswqs commited on
Commit
254ed4c
1 Parent(s): c6e60d9

Added WMS web app

Browse files
Files changed (2) hide show
  1. app.py +13 -1
  2. apps/wms.py +47 -0
app.py CHANGED
@@ -1,6 +1,17 @@
1
  import streamlit as st
2
  from multiapp import MultiApp
3
- from apps import basemaps, heatmap, gee, gee_datasets, home, census, deck, housing, upload
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  st.set_page_config(layout="wide")
6
 
@@ -16,6 +27,7 @@ apps.add_app("Upload Vector Data", upload.app)
16
  apps.add_app("Search Basemaps", basemaps.app)
17
  apps.add_app("Pydeck Gallery", deck.app)
18
  apps.add_app("Heatmaps", heatmap.app)
 
19
  apps.add_app("Google Earth Engine (GEE)", gee.app)
20
  apps.add_app("Awesome GEE Community Datasets", gee_datasets.app)
21
 
 
1
  import streamlit as st
2
  from multiapp import MultiApp
3
+ from apps import (
4
+ basemaps,
5
+ heatmap,
6
+ gee,
7
+ gee_datasets,
8
+ home,
9
+ census,
10
+ deck,
11
+ housing,
12
+ upload,
13
+ wms,
14
+ )
15
 
16
  st.set_page_config(layout="wide")
17
 
 
27
  apps.add_app("Search Basemaps", basemaps.app)
28
  apps.add_app("Pydeck Gallery", deck.app)
29
  apps.add_app("Heatmaps", heatmap.app)
30
+ apps.add_app("Add Web Map Service (WMS)", wms.app)
31
  apps.add_app("Google Earth Engine (GEE)", gee.app)
32
  apps.add_app("Awesome GEE Community Datasets", gee_datasets.app)
33
 
apps/wms.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import leafmap.foliumap as leafmap
3
+
4
+
5
+ def app():
6
+ st.title("Add Web Map Service (WMS)")
7
+ st.markdown(
8
+ """
9
+ This app is a demonstration of loading Web Map Service (WMS) layers. Simply enter the URL of the WMS service
10
+ in the text box below and press Enter to retrieve the layers. Go to https://apps.nationalmap.gov/services to find
11
+ some WMS URLs if needed.
12
+ """
13
+ )
14
+
15
+ row1_col1, row1_col2, _ = st.columns([2, 1, 0.5])
16
+ width = 800
17
+ height = 600
18
+ layers = None
19
+
20
+ with row1_col2:
21
+
22
+ esa_landcover = "https://services.terrascope.be/wms/v2"
23
+ url = st.text_input(
24
+ "Enter a WMS URL:", value="https://services.terrascope.be/wms/v2"
25
+ )
26
+ empty = st.empty()
27
+
28
+ if url:
29
+ options = leafmap.get_wms_layers(url)
30
+
31
+ default = None
32
+ if url == esa_landcover:
33
+ default = "WORLDCOVER_2020_MAP"
34
+ layers = empty.multiselect(
35
+ "Select WMS layers to add to the map:", options, default=default
36
+ )
37
+
38
+ with row1_col1:
39
+ m = leafmap.Map(center=(36.3, 0), zoom=2)
40
+
41
+ if layers is not None:
42
+ for layer in layers:
43
+ m.add_wms_layer(
44
+ url, layers=layer, name=layer, attribution=" ", transparent=True
45
+ )
46
+
47
+ m.to_streamlit(width, height)