{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating Landsat Timelapse\n", "\n", "**Steps to create a Landsat timelapse:**\n", "\n", "1. Pan and zoom to your region of interest.\n", "2. Use the drawing tool to draw a rectangle anywhere on the map.\n", "3. Adjust the parameters (e.g., start year, end year, title) if needed.\n", "4. Check `Download the GIF` if you would like to download the timelapse GIF.\n", "5. Click the Submit button to create a timelapse.\n", "6. Deploy the app to [heroku](https://www.heroku.com/). See https://github.com/giswqs/earthengine-apps" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import ee\n", "import geemap\n", "import ipywidgets as widgets" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')\n", "if not os.path.exists(out_dir):\n", " os.makedirs(out_dir)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "style = {'description_width': 'initial'}\n", "title = widgets.Text(\n", " description='Title:', value='Landsat Timelapse', width=200, style=style\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bands = widgets.Dropdown(\n", " description='Select RGB Combo:',\n", " options=[\n", " 'Red/Green/Blue',\n", " 'NIR/Red/Green',\n", " 'SWIR2/SWIR1/NIR',\n", " 'NIR/SWIR1/Red',\n", " 'SWIR2/NIR/Red',\n", " 'SWIR2/SWIR1/Red',\n", " 'SWIR1/NIR/Blue',\n", " 'NIR/SWIR1/Blue',\n", " 'SWIR2/NIR/Green',\n", " 'SWIR1/NIR/Red',\n", " ],\n", " value='NIR/Red/Green',\n", " style=style,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hbox1 = widgets.HBox([title, bands])\n", "hbox1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "start_year = widgets.IntSlider(\n", " description='Start Year:', value=1984, min=1984, max=2021, style=style\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "end_year = widgets.IntSlider(\n", " description='End Year:', value=2021, min=1984, max=2021, style=style\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hbox2 = widgets.HBox([start_year, end_year])\n", "hbox2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "speed = widgets.IntSlider(\n", " description='Frames per second:',\n", " tooltip='Frames per second:',\n", " value=10,\n", " min=1,\n", " max=30,\n", " style=style,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "download = widgets.Checkbox(value=False, description='Download the GIF', style=style)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hbox3 = widgets.HBox([speed, download])\n", "hbox3" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "font_size = widgets.IntSlider(\n", " description='Font size:', value=30, min=10, max=50, style=style\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "font_color = widgets.ColorPicker(\n", " concise=False, description='Font color:', value='white', style=style\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "progress_bar_color = widgets.ColorPicker(\n", " concise=False, description='Progress bar color:', value='blue', style=style\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hbox4 = widgets.HBox([font_size, font_color, progress_bar_color])\n", "hbox4" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "submit = widgets.Button(\n", " description='Submit',\n", " button_style='primary',\n", " tooltip='Click the submit the request to create timelapse',\n", " style=style,\n", ")\n", "\n", "output = widgets.Output()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def submit_clicked(b):\n", " with output:\n", " output.clear_output()\n", " if start_year.value >= end_year.value:\n", " print('The end year must be great than the start year.')\n", " return\n", " print('Computing...')\n", "\n", " Map.add_landsat_ts_gif(\n", " roi=Map.user_roi,\n", " label=title.value,\n", " start_year=start_year.value,\n", " end_year=end_year.value,\n", " start_date='05-01',\n", " end_date='10-31',\n", " bands=bands.value.split('/'),\n", " font_color=font_color.value,\n", " frames_per_second=speed.value,\n", " font_size=font_size.value,\n", " progress_bar_color=progress_bar_color.value,\n", " download=download.value,\n", " )\n", "\n", "\n", "submit.on_click(submit_clicked)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "submit" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "output" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }