27 timelapse app
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
Creating Landsat Timelapse¶
Steps to create a Landsat timelapse:
- Pan and zoom to your region of interest.
- Use the drawing tool to draw a rectangle anywhere on the map.
- Adjust the parameters (e.g., start year, end year, title) if needed.
- Check
Download the GIF
if you would like to download the timelapse GIF. - Click the Submit button to create a timelapse.
- Deploy the app to heroku. See https://github.com/giswqs/earthengine-apps
In [2]:
Copied!
import os
import ee
import geemap
import ipywidgets as widgets
import os
import ee
import geemap
import ipywidgets as widgets
In [3]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
Copied!
out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
In [5]:
Copied!
style = {'description_width': 'initial'}
title = widgets.Text(
description='Title:', value='Landsat Timelapse', width=200, style=style
)
style = {'description_width': 'initial'}
title = widgets.Text(
description='Title:', value='Landsat Timelapse', width=200, style=style
)
In [6]:
Copied!
bands = widgets.Dropdown(
description='Select RGB Combo:',
options=[
'Red/Green/Blue',
'NIR/Red/Green',
'SWIR2/SWIR1/NIR',
'NIR/SWIR1/Red',
'SWIR2/NIR/Red',
'SWIR2/SWIR1/Red',
'SWIR1/NIR/Blue',
'NIR/SWIR1/Blue',
'SWIR2/NIR/Green',
'SWIR1/NIR/Red',
],
value='NIR/Red/Green',
style=style,
)
bands = widgets.Dropdown(
description='Select RGB Combo:',
options=[
'Red/Green/Blue',
'NIR/Red/Green',
'SWIR2/SWIR1/NIR',
'NIR/SWIR1/Red',
'SWIR2/NIR/Red',
'SWIR2/SWIR1/Red',
'SWIR1/NIR/Blue',
'NIR/SWIR1/Blue',
'SWIR2/NIR/Green',
'SWIR1/NIR/Red',
],
value='NIR/Red/Green',
style=style,
)
In [7]:
Copied!
hbox1 = widgets.HBox([title, bands])
hbox1
hbox1 = widgets.HBox([title, bands])
hbox1
In [8]:
Copied!
start_year = widgets.IntSlider(
description='Start Year:', value=1984, min=1984, max=2021, style=style
)
start_year = widgets.IntSlider(
description='Start Year:', value=1984, min=1984, max=2021, style=style
)
In [9]:
Copied!
end_year = widgets.IntSlider(
description='End Year:', value=2021, min=1984, max=2021, style=style
)
end_year = widgets.IntSlider(
description='End Year:', value=2021, min=1984, max=2021, style=style
)
In [10]:
Copied!
hbox2 = widgets.HBox([start_year, end_year])
hbox2
hbox2 = widgets.HBox([start_year, end_year])
hbox2
In [11]:
Copied!
speed = widgets.IntSlider(
description='Frames per second:',
tooltip='Frames per second:',
value=10,
min=1,
max=30,
style=style,
)
speed = widgets.IntSlider(
description='Frames per second:',
tooltip='Frames per second:',
value=10,
min=1,
max=30,
style=style,
)
In [12]:
Copied!
download = widgets.Checkbox(value=False, description='Download the GIF', style=style)
download = widgets.Checkbox(value=False, description='Download the GIF', style=style)
In [13]:
Copied!
hbox3 = widgets.HBox([speed, download])
hbox3
hbox3 = widgets.HBox([speed, download])
hbox3
In [14]:
Copied!
font_size = widgets.IntSlider(
description='Font size:', value=30, min=10, max=50, style=style
)
font_size = widgets.IntSlider(
description='Font size:', value=30, min=10, max=50, style=style
)
In [15]:
Copied!
font_color = widgets.ColorPicker(
concise=False, description='Font color:', value='white', style=style
)
font_color = widgets.ColorPicker(
concise=False, description='Font color:', value='white', style=style
)
In [16]:
Copied!
progress_bar_color = widgets.ColorPicker(
concise=False, description='Progress bar color:', value='blue', style=style
)
progress_bar_color = widgets.ColorPicker(
concise=False, description='Progress bar color:', value='blue', style=style
)
In [17]:
Copied!
hbox4 = widgets.HBox([font_size, font_color, progress_bar_color])
hbox4
hbox4 = widgets.HBox([font_size, font_color, progress_bar_color])
hbox4
In [18]:
Copied!
submit = widgets.Button(
description='Submit',
button_style='primary',
tooltip='Click the submit the request to create timelapse',
style=style,
)
output = widgets.Output()
submit = widgets.Button(
description='Submit',
button_style='primary',
tooltip='Click the submit the request to create timelapse',
style=style,
)
output = widgets.Output()
In [19]:
Copied!
def submit_clicked(b):
with output:
output.clear_output()
if start_year.value >= end_year.value:
print('The end year must be great than the start year.')
return
print('Computing...')
Map.add_landsat_ts_gif(
roi=Map.user_roi,
label=title.value,
start_year=start_year.value,
end_year=end_year.value,
start_date='05-01',
end_date='10-31',
bands=bands.value.split('/'),
font_color=font_color.value,
frames_per_second=speed.value,
font_size=font_size.value,
progress_bar_color=progress_bar_color.value,
download=download.value,
)
submit.on_click(submit_clicked)
def submit_clicked(b):
with output:
output.clear_output()
if start_year.value >= end_year.value:
print('The end year must be great than the start year.')
return
print('Computing...')
Map.add_landsat_ts_gif(
roi=Map.user_roi,
label=title.value,
start_year=start_year.value,
end_year=end_year.value,
start_date='05-01',
end_date='10-31',
bands=bands.value.split('/'),
font_color=font_color.value,
frames_per_second=speed.value,
font_size=font_size.value,
progress_bar_color=progress_bar_color.value,
download=download.value,
)
submit.on_click(submit_clicked)
In [20]:
Copied!
submit
submit
In [21]:
Copied!
output
output
Last update:
2022-03-14