giswqs commited on
Commit
93b383c
Β·
1 Parent(s): 345f975

Added search locations

Browse files
Files changed (1) hide show
  1. apps/timelapse.py +20 -3
apps/timelapse.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import datetime
3
  import geopandas as gpd
 
4
  import streamlit as st
5
  import geemap.foliumap as geemap
6
  from datetime import date
@@ -46,8 +47,24 @@ def app():
46
 
47
  row1_col1, row1_col2 = st.columns([2, 1])
48
 
 
 
 
 
49
  with row1_col2:
50
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  collection = st.selectbox(
52
  "Select a satellite image collection: ",
53
  [
@@ -71,8 +88,8 @@ def app():
71
  )
72
 
73
  with row1_col1:
74
- m = geemap.Map(basemap="HYBRID", plugin_Draw=True, draw_export=True)
75
- m.add_basemap("ROADMAP")
76
 
77
  with st.expander("Steps: Draw a rectangle on the map -> Export it as a GeoJSON -> Upload it back to the app -> Click the Submit button. Expand this tab to see a demo πŸ‘‰"):
78
  video_empty = st.empty()
@@ -88,7 +105,7 @@ def app():
88
  # st.info(
89
  # "Steps to create a timelapse: Draw a rectangle on the map -> Export it as a GeoJSON -> Upload it back to the app -> Click Submit button"
90
  # )
91
- if collection == "Landsat TM-ETM-OLI Surface Reflectance":
92
  try:
93
  # lat, lon = geemap.get_current_latlon()
94
  m.set_center(4.20, 18.63, zoom=2)
 
1
  import os
2
  import datetime
3
  import geopandas as gpd
4
+ import folium
5
  import streamlit as st
6
  import geemap.foliumap as geemap
7
  from datetime import date
 
47
 
48
  row1_col1, row1_col2 = st.columns([2, 1])
49
 
50
+ with row1_col1:
51
+ m = geemap.Map(basemap="HYBRID", plugin_Draw=True, draw_export=True)
52
+ m.add_basemap("ROADMAP")
53
+
54
  with row1_col2:
55
 
56
+ keyword = st.text_input("Search for a location:", "")
57
+ if keyword:
58
+ locations = geemap.geocode(keyword)
59
+ if locations is not None and len(locations) > 0:
60
+ str_locations = [str(g)[1:-1] for g in locations]
61
+ location = st.selectbox("Select a location:", str_locations)
62
+ loc_index = str_locations.index(location)
63
+ selected_loc = locations[loc_index]
64
+ lat, lng = selected_loc.lat, selected_loc.lng
65
+ folium.Marker(location=[lat, lng], popup=location).add_to(m)
66
+ m.set_center(lng, lat, 12)
67
+
68
  collection = st.selectbox(
69
  "Select a satellite image collection: ",
70
  [
 
88
  )
89
 
90
  with row1_col1:
91
+ # m = geemap.Map(basemap="HYBRID", plugin_Draw=True, draw_export=True)
92
+ # m.add_basemap("ROADMAP")
93
 
94
  with st.expander("Steps: Draw a rectangle on the map -> Export it as a GeoJSON -> Upload it back to the app -> Click the Submit button. Expand this tab to see a demo πŸ‘‰"):
95
  video_empty = st.empty()
 
105
  # st.info(
106
  # "Steps to create a timelapse: Draw a rectangle on the map -> Export it as a GeoJSON -> Upload it back to the app -> Click Submit button"
107
  # )
108
+ if collection == "Landsat TM-ETM-OLI Surface Reflectance" and (not keyword):
109
  try:
110
  # lat, lon = geemap.get_current_latlon()
111
  m.set_center(4.20, 18.63, zoom=2)