Spaces:
Sleeping
Sleeping
Updated timelapse app
Browse files- apps/timelapse.py +16 -6
apps/timelapse.py
CHANGED
@@ -14,7 +14,8 @@ def uploaded_file_to_gdf(data):
|
|
14 |
|
15 |
_, file_extension = os.path.splitext(data.name)
|
16 |
file_id = str(uuid.uuid4())
|
17 |
-
file_path = os.path.join(tempfile.gettempdir(),
|
|
|
18 |
|
19 |
with open(file_path, "wb") as file:
|
20 |
file.write(data.getbuffer())
|
@@ -34,6 +35,12 @@ def app():
|
|
34 |
|
35 |
st.title("Create Landsat Timelapse")
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
row1_col1, row1_col2 = st.columns([2, 1])
|
38 |
|
39 |
with row1_col1:
|
@@ -41,7 +48,7 @@ def app():
|
|
41 |
m.add_basemap("ROADMAP")
|
42 |
|
43 |
data = st.file_uploader(
|
44 |
-
"Draw a small ROI on the map, click the Export button to save it, and then upload it here 😇👇",
|
45 |
type=["geojson"],
|
46 |
)
|
47 |
|
@@ -62,7 +69,7 @@ def app():
|
|
62 |
gdf = gpd.GeoDataFrame(index=[0], crs=crs, geometry=[polygon_geom])
|
63 |
st.session_state["roi"] = geemap.geopandas_to_ee(gdf)
|
64 |
m.add_gdf(gdf, "ROI", zoom_to_layer=True)
|
65 |
-
m.to_streamlit(height=
|
66 |
|
67 |
with row1_col2:
|
68 |
with st.form("submit_form"):
|
@@ -100,9 +107,11 @@ def app():
|
|
100 |
with st.expander("Customize timelapse"):
|
101 |
|
102 |
speed = st.slider("Frames/sec:", 1, 30, 10)
|
103 |
-
progress_bar_color = st.color_picker(
|
|
|
104 |
years = st.slider(
|
105 |
-
"Start and end year:", 1984, today.year, (
|
|
|
106 |
)
|
107 |
months = st.slider("Start and end month:", 1, 12, (5, 10))
|
108 |
font_size = st.slider("Font size:", 10, 50, 30)
|
@@ -162,5 +171,6 @@ def app():
|
|
162 |
|
163 |
geemap.reduce_gif_size(out_gif)
|
164 |
|
165 |
-
empty_text.text(
|
|
|
166 |
empty_image.image(out_gif)
|
|
|
14 |
|
15 |
_, file_extension = os.path.splitext(data.name)
|
16 |
file_id = str(uuid.uuid4())
|
17 |
+
file_path = os.path.join(tempfile.gettempdir(),
|
18 |
+
f"{file_id}{file_extension}")
|
19 |
|
20 |
with open(file_path, "wb") as file:
|
21 |
file.write(data.getbuffer())
|
|
|
35 |
|
36 |
st.title("Create Landsat Timelapse")
|
37 |
|
38 |
+
st.markdown("""
|
39 |
+
An interactive web app for creating timelapse of annual Landsat imagery (1984-2021) for any location around the globe.
|
40 |
+
The app was built using [streamlit](https://streamlit.io), [geemap](https://geemap.org), and [Google Earth Engine](https://earthengine.google.com).
|
41 |
+
See a [video demo] (https://youtu.be/VVRK_-dEjR4).
|
42 |
+
""")
|
43 |
+
|
44 |
row1_col1, row1_col2 = st.columns([2, 1])
|
45 |
|
46 |
with row1_col1:
|
|
|
48 |
m.add_basemap("ROADMAP")
|
49 |
|
50 |
data = st.file_uploader(
|
51 |
+
"Draw a small ROI on the map, click the Export button to save it, and then upload it here. Customize timelapse parameters and then click the Submit button 😇👇",
|
52 |
type=["geojson"],
|
53 |
)
|
54 |
|
|
|
69 |
gdf = gpd.GeoDataFrame(index=[0], crs=crs, geometry=[polygon_geom])
|
70 |
st.session_state["roi"] = geemap.geopandas_to_ee(gdf)
|
71 |
m.add_gdf(gdf, "ROI", zoom_to_layer=True)
|
72 |
+
m.to_streamlit(height=600)
|
73 |
|
74 |
with row1_col2:
|
75 |
with st.form("submit_form"):
|
|
|
107 |
with st.expander("Customize timelapse"):
|
108 |
|
109 |
speed = st.slider("Frames/sec:", 1, 30, 10)
|
110 |
+
progress_bar_color = st.color_picker(
|
111 |
+
"Progress bar color:", "#0000ff")
|
112 |
years = st.slider(
|
113 |
+
"Start and end year:", 1984, today.year, (
|
114 |
+
1984, today.year - 1)
|
115 |
)
|
116 |
months = st.slider("Start and end month:", 1, 12, (5, 10))
|
117 |
font_size = st.slider("Font size:", 10, 50, 30)
|
|
|
171 |
|
172 |
geemap.reduce_gif_size(out_gif)
|
173 |
|
174 |
+
empty_text.text(
|
175 |
+
"Right click the image to save it to your computer👇")
|
176 |
empty_image.image(out_gif)
|