{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Creating Satellite Image Time Series and Timelapse Animations\n", "\n", "[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/gee-community/geemap/blob/master/examples/workshops/GEE_Workshop_2022_Part1.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import libraries" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# pip install geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.ee_initialize()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The map function" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "myList = ee.List.sequence(1, 10)\n", "print(myList.getInfo())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def computeSquares(number):\n", " return ee.Number(number).pow(2)\n", "\n", "\n", "squares = myList.map(computeSquares)\n", "print(squares.getInfo())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "squares = myList.map(lambda number: ee.Number(number).pow(2))\n", "print(squares.getInfo())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating cloud-free composites" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "fc = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(\n", " ee.Filter.eq('country_na', 'Netherlands')\n", ")\n", "\n", "Map.addLayer(fc, {'color': 'ff000000'}, \"Netherlands\")\n", "Map.centerObject(fc)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "years = ee.List.sequence(2013, 2021)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "def yearly_image(year):\n", " start_date = ee.Date.fromYMD(year, 1, 1)\n", " end_date = start_date.advance(1, \"year\")\n", "\n", " collection = (\n", " ee.ImageCollection('LANDSAT/LC08/C01/T1')\n", " .filterDate(start_date, end_date)\n", " .filterBounds(fc)\n", " )\n", "\n", " image = ee.Algorithms.Landsat.simpleComposite(collection).clipToCollection(fc)\n", "\n", " return image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "images = years.map(yearly_image)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vis_params = {'bands': ['B5', 'B4', 'B3'], 'max': 128}\n", "for index in range(0, 9):\n", " image = ee.Image(images.get(index))\n", " layer_name = \"Year \" + str(index + 2013)\n", " Map.addLayer(image, vis_params, layer_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating timeseries" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "collection = ee.ImageCollection(\"COPERNICUS/S2_HARMONIZED\").filterMetadata(\n", " 'CLOUDY_PIXEL_PERCENTAGE', 'less_than', 10\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "start_date = '2016-01-01'\n", "end_date = '2022-12-31'\n", "region = ee.Geometry.BBox(-122.5549, 37.6968, -122.3446, 37.8111)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "images = geemap.create_timeseries(\n", " collection, start_date, end_date, region, frequency='year', reducer='median'\n", ")\n", "images.size().getInfo()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "\n", "vis_params = {\"min\": 0, \"max\": 4000, \"bands\": [\"B8\", \"B4\", \"B3\"]}\n", "labels = [str(y) for y in range(2016, 2023)]\n", "\n", "Map.addLayer(images, vis_params, \"Sentinel-2\", False)\n", "Map.add_time_slider(images, vis_params, time_interval=2, labels=labels)\n", "Map.centerObject(region)\n", "Map" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## NAIP timelapse" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map(center=[40, -100], zoom=4)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(-99.1019, 47.1274, -99.0334, 47.1562)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "collection = geemap.naip_timeseries(roi, start_year=2009, end_year=2022, RGBN=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "years = geemap.image_dates(collection, date_format='YYYY').getInfo()\n", "print(years)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "size = len(years)\n", "images = collection.toList(size)\n", "for i in range(size):\n", " image = ee.Image(images.get(i))\n", " Map.addLayer(image, {'bands': ['N', 'R', 'G']}, years[i])\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.naip_timelapse(\n", " roi,\n", " out_gif=\"naip.gif\",\n", " bands=['N', 'R', 'G'],\n", " frames_per_second=3,\n", " title='NAIP Timelapse',\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/Me6D78k.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Landsat timelapse" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(-74.7222, -8.5867, -74.1596, -8.2824)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.landsat_timelapse(\n", " roi,\n", " out_gif='landsat.gif',\n", " start_year=1984,\n", " end_year=2022,\n", " start_date='01-01',\n", " end_date='12-31',\n", " bands=['SWIR1', 'NIR', 'Red'],\n", " frames_per_second=5,\n", " title='Landsat Timelapse',\n", " progress_bar_color='blue',\n", " mp4=True,\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/VL1V1Y4.gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "roi = ee.Geometry.BBox(-115.5541, 35.8044, -113.9035, 36.5581)\n", "Map.addLayer(roi)\n", "Map.centerObject(roi)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.landsat_timelapse(\n", " roi,\n", " out_gif='las_vegas.gif',\n", " start_year=1984,\n", " end_year=2022,\n", " bands=['NIR', 'Red', 'Green'],\n", " frames_per_second=5,\n", " title='Las Vegas, NV',\n", " font_color='blue',\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/LzWyyZW.gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "roi = ee.Geometry.BBox(113.8252, 22.1988, 114.0851, 22.3497)\n", "Map.addLayer(roi)\n", "Map.centerObject(roi)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.landsat_timelapse(\n", " roi,\n", " out_gif='hong_kong.gif',\n", " start_year=1990,\n", " end_year=2022,\n", " start_date='01-01',\n", " end_date='12-31',\n", " bands=['SWIR1', 'NIR', 'Red'],\n", " frames_per_second=3,\n", " title='Hong Kong',\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/0nLRj22.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sentinel-1 timelapse" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(117.1132, 3.5227, 117.2214, 3.5843)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.sentinel1_timelapse(\n", " roi,\n", " out_gif='sentinel1.gif',\n", " start_year=2019,\n", " end_year=2019,\n", " start_date='04-01',\n", " end_date='08-01',\n", " frequency='day',\n", " vis_params={\"min\": -30, \"max\": 0},\n", " palette=\"Greys\",\n", " frames_per_second=3,\n", " title='Sentinel-1 Timelapse',\n", " add_colorbar=True,\n", " colorbar_bg_color='gray',\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sentinel-2 timelapse" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(-74.7222, -8.5867, -74.1596, -8.2824)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.sentinel2_timelapse(\n", " roi,\n", " out_gif='sentinel2.gif',\n", " start_year=2016,\n", " end_year=2021,\n", " start_date='01-01',\n", " end_date='12-31',\n", " frequency='year',\n", " bands=['SWIR1', 'NIR', 'Red'],\n", " frames_per_second=3,\n", " title='Sentinel-2 Timelapse',\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/BmQdo9j.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## MODIS timelapse\n", "\n", "### MODIS NDVI" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(-18.6983, -36.1630, 52.2293, 38.1446)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.modis_ndvi_timelapse(\n", " roi,\n", " out_gif='ndvi.gif',\n", " data='Terra',\n", " band='NDVI',\n", " start_date='2000-01-01',\n", " end_date='2021-12-31',\n", " frames_per_second=3,\n", " title='MODIS NDVI Timelapse',\n", " overlay_data='countries',\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/KZwf8c2.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### MODIS temperature" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(-171.21, -57.13, 177.53, 79.99)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.modis_ocean_color_timelapse(\n", " satellite='Aqua',\n", " start_date='2018-01-01',\n", " end_date='2020-12-31',\n", " roi=roi,\n", " frequency='month',\n", " out_gif='temperature.gif',\n", " overlay_data='continents',\n", " overlay_color='yellow',\n", " overlay_opacity=0.5,\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/ELVn5jq.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## GOES timelapse" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = Map.user_roi\n", "if roi is None:\n", " roi = ee.Geometry.BBox(167.1898, -28.5757, 202.6258, -12.4411)\n", " Map.addLayer(roi)\n", " Map.centerObject(roi)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "start_date = \"2022-01-15T03:00:00\"\n", "end_date = \"2022-01-15T07:00:00\"\n", "data = \"GOES-17\"\n", "scan = \"full_disk\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.goes_timelapse(\n", " roi, \"goes.gif\", start_date, end_date, data, scan, framesPerSecond=5\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/l67i6Pj.gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = ee.Geometry.BBox(-159.5954, 24.5178, -114.2438, 60.4088)\n", "start_date = \"2021-10-24T14:00:00\"\n", "end_date = \"2021-10-25T01:00:00\"\n", "data = \"GOES-17\"\n", "scan = \"full_disk\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.goes_timelapse(\n", " roi, \"hurricane.gif\", start_date, end_date, data, scan, framesPerSecond=5\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/zYt2b8d.gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map()\n", "roi = ee.Geometry.BBox(-121.0034, 36.8488, -117.9052, 39.0490)\n", "Map.addLayer(roi)\n", "Map.centerObject(roi)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "start_date = \"2020-09-05T15:00:00\"\n", "end_date = \"2020-09-06T02:00:00\"\n", "data = \"GOES-17\"\n", "scan = \"full_disk\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.goes_fire_timelapse(\n", " roi, \"fire.gif\", start_date, end_date, data, scan, framesPerSecond=5\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/pgPjuLS.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fading effects" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "in_gif = \"https://i.imgur.com/ZWSZC5z.gif\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(in_gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_gif = \"gif_fading.gif\"\n", "geemap.gif_fading(in_gif, out_gif, verbose=False)\n", "geemap.show_image(out_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/PbK89b6.gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "roi = ee.Geometry.BBox(-69.3154, -22.8371, -69.1900, -22.7614)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "timelapse = geemap.landsat_timelapse(\n", " roi,\n", " out_gif='mines.gif',\n", " start_year=2004,\n", " end_year=2010,\n", " frames_per_second=1,\n", " title='Copper mines, Chile',\n", " fading=True,\n", ")\n", "geemap.show_image(timelapse)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/1ZbWs66.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding animated text\n", "\n", "### Add animated text to an existing GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = 'https://github.com/gee-community/geemap/raw/master/examples/data/animation.gif'\n", "filename = 'animation.gif'\n", "geemap.download_file(url, filename)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(filename)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Add animated text to GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_gif = 'timelapse.gif'\n", "geemap.add_text_to_gif(\n", " filename,\n", " out_gif,\n", " xy=('5%', '5%'),\n", " text_sequence=1984,\n", " font_size=30,\n", " font_color='#0000ff',\n", " duration=100,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(out_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Add place name" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.add_text_to_gif(\n", " out_gif, out_gif, xy=('35%', '85%'), text_sequence=\"Las Vegas\", font_color='black'\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(out_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create GIF from Earth Engine data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Prepare for an ImageCollection" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap\n", "\n", "geemap.ee_initialize()\n", "\n", "# Define an area of interest geometry with a global non-polar extent.\n", "aoi = ee.Geometry.Polygon(\n", " [[[-179.0, 78.0], [-179.0, -58.0], [179.0, -58.0], [179.0, 78.0]]], None, False\n", ")\n", "\n", "# Import hourly predicted temperature image collection for northern winter\n", "# solstice. Note that predictions extend for 384 hours; limit the collection\n", "# to the first 24 hours.\n", "tempCol = (\n", " ee.ImageCollection('NOAA/GFS0P25')\n", " .filterDate('2018-12-22', '2018-12-23')\n", " .limit(24)\n", " .select('temperature_2m_above_ground')\n", ")\n", "\n", "# Define arguments for animation function parameters.\n", "videoArgs = {\n", " 'dimensions': 768,\n", " 'region': aoi,\n", " 'framesPerSecond': 10,\n", " 'crs': 'EPSG:3857',\n", " 'min': -40.0,\n", " 'max': 35.0,\n", " 'palette': ['blue', 'purple', 'cyan', 'green', 'yellow', 'red'],\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Save the GIF to local drive" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "saved_gif = 'temperature.gif'\n", "geemap.download_ee_video(tempCol, videoArgs, saved_gif)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(saved_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Generate an hourly text sequence" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "text = [str(n).zfill(2) + \":00\" for n in range(0, 24)]\n", "print(text)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Add text to GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_gif = 'output2.gif'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.add_text_to_gif(\n", " saved_gif,\n", " out_gif,\n", " xy=('3%', '5%'),\n", " text_sequence=text,\n", " font_size=30,\n", " font_color='#ffffff',\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.add_text_to_gif(\n", " out_gif,\n", " out_gif,\n", " xy=('32%', '92%'),\n", " text_sequence='NOAA GFS Hourly Temperature',\n", " font_color='white',\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(out_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Adding colorbar to an image" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "#### Download a GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = 'https://i.imgur.com/MSde1om.gif'\n", "in_gif = 'temp.gif'\n", "geemap.download_file(url, 'temp.gif')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(in_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Get image URLs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "noaa_logo = 'https://bit.ly/3ahJoMq'\n", "ee_logo = 'https://i.imgur.com/Qbvacvm.jpg'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Set output GIF path" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "out_gif = 'output.gif'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Add images to GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.add_image_to_gif(\n", " in_gif, out_gif, in_image=noaa_logo, xy=('2%', '80%'), image_size=(80, 80)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.add_image_to_gif(\n", " out_gif, out_gif, in_image=ee_logo, xy=('13%', '79%'), image_size=(85, 85)\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Display output GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(out_gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Create a colorbar" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "width = 250\n", "height = 30\n", "palette = ['blue', 'purple', 'cyan', 'green', 'yellow', 'red']\n", "labels = [-40, 35]\n", "colorbar = geemap.create_colorbar(\n", " width=width,\n", " height=height,\n", " palette=palette,\n", " vertical=False,\n", " add_labels=True,\n", " font_size=20,\n", " labels=labels,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(colorbar)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Add colorbar to GIF" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.add_image_to_gif(\n", " out_gif, out_gif, in_image=colorbar, xy=('69%', '89%'), image_size=(250, 250)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.show_image(out_gif)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }