giswqs commited on
Commit
5b1eafc
·
1 Parent(s): 5a0a108

Added points from xy app #14

Browse files
Files changed (2) hide show
  1. app.py +2 -0
  2. apps/xy.py +45 -0
app.py CHANGED
@@ -15,6 +15,7 @@ from apps import (
15
  timelapse,
16
  vector,
17
  wms,
 
18
  )
19
 
20
  st.set_page_config(layout="wide")
@@ -33,6 +34,7 @@ apps.add_app("Visualize Vector Data", vector.app)
33
  apps.add_app("Search Basemaps", basemaps.app)
34
  apps.add_app("Pydeck Gallery", deck.app)
35
  apps.add_app("Heatmaps", heatmap.app)
 
36
  apps.add_app("Add Web Map Service (WMS)", wms.app)
37
  apps.add_app("Google Earth Engine (GEE)", gee.app)
38
  apps.add_app("Awesome GEE Community Datasets", gee_datasets.app)
 
15
  timelapse,
16
  vector,
17
  wms,
18
+ xy,
19
  )
20
 
21
  st.set_page_config(layout="wide")
 
34
  apps.add_app("Search Basemaps", basemaps.app)
35
  apps.add_app("Pydeck Gallery", deck.app)
36
  apps.add_app("Heatmaps", heatmap.app)
37
+ apps.add_app("Add Points from XY", xy.app)
38
  apps.add_app("Add Web Map Service (WMS)", wms.app)
39
  apps.add_app("Google Earth Engine (GEE)", gee.app)
40
  apps.add_app("Awesome GEE Community Datasets", gee_datasets.app)
apps/xy.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import leafmap.foliumap as leafmap
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ def app():
7
+
8
+ st.title("Add Points from XY")
9
+
10
+ sample_url = "https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/world_cities.csv"
11
+ url = st.text_input("Enter URL:", sample_url)
12
+ m = leafmap.Map(locate_control=True, plugin_LatLngPopup=False)
13
+
14
+ if url:
15
+
16
+ try:
17
+ df = pd.read_csv(url)
18
+
19
+ columns = df.columns.values.tolist()
20
+ row1_col1, row1_col2, row1_col3 = st.columns([1, 1, 2])
21
+
22
+ lon_index = 0
23
+ lat_index = 0
24
+
25
+ for col in columns:
26
+ if col.lower() in ["lon", "longitude", "long", "lng"]:
27
+ lon_index = columns.index(col)
28
+ elif col.lower() in ["lat", "latitude"]:
29
+ lat_index = columns.index(col)
30
+
31
+ with row1_col1:
32
+ x = st.selectbox("Select longitude column", columns, lon_index)
33
+
34
+ with row1_col2:
35
+ y = st.selectbox("Select latitude column", columns, lat_index)
36
+
37
+ with row1_col3:
38
+ popups = st.multiselect("Select popup columns", columns, columns)
39
+
40
+ m.add_points_from_xy(df, x, y, popups)
41
+
42
+ except Exception as e:
43
+ st.error(e)
44
+
45
+ m.to_streamlit()