#!/usr/bin/env python # coding: utf-8 # In[ ]: import geemap import os # In[ ]: geemap.show_youtube('fDnDVuM_Ke4') # ## Update the geemap package # # If you run into errors with this notebook, please uncomment the line below to update the [geemap](https://github.com/giswqs/geemap#installation) package to the latest version from GitHub. # Restart the Kernel (Menu -> Kernel -> Restart) to take effect. # In[ ]: # geemap.update_package() # ## Add animated text to an existing GIF # # You can download this GIF example from [here](https://github.com/giswqs/geemap/blob/master/examples/data/animation.gif). You can also create GIF images from Earth Engine data using this amazing [LT-GEE Time Series Animator](https://emaprlab.users.earthengine.app/view/lt-gee-time-series-animator), which was created by [Justin Braaten](https://github.com/jdbcode). # In[ ]: in_gif = os.path.abspath('../data/animation.gif') out_gif = os.path.join(os.path.expanduser('~'), 'Downloads/output.gif') # In[ ]: geemap.show_image(in_gif) # ### Add animated text to GIF # In[ ]: geemap.add_text_to_gif(in_gif, out_gif, xy=('5%', '5%'), text_sequence=1984, font_size=30, font_color='#0000ff', duration=100) # In[ ]: geemap.show_image(out_gif) # ### Add place name # In[ ]: geemap.add_text_to_gif(out_gif, out_gif, xy=('30%', '85%'), text_sequence="Las Vegas", font_color='black') # In[ ]: geemap.show_image(out_gif) # ### Change font type # In[ ]: geemap.system_fonts() # In[ ]: geemap.add_text_to_gif(in_gif, out_gif, xy=('5%', '5%'), text_sequence=1984, font_size=30, font_color='#0000ff', duration=100) geemap.add_text_to_gif(out_gif, out_gif, xy=('30%', '85%'), text_sequence="Las Vegas", font_type="timesbd.ttf", font_size = 30, font_color='black') geemap.show_image(out_gif) # ## Create GIF from Earth Engine data # # This example was adapted from the Earth Engine JavaScript API Documentation [here](https://developers.google.com/earth-engine/ic_visualization#video_thumb). # ### Prepare for an ImageCollection # In[ ]: import ee import geemap ee.Initialize() # Define an area of interest geometry with a global non-polar extent. aoi = ee.Geometry.Polygon( [[[-179.0, 78.0], [-179.0, -58.0], [179.0, -58.0], [179.0, 78.0]]], None, False) # Import hourly predicted temperature image collection for northern winter # solstice. Note that predictions extend for 384 hours; limit the collection # to the first 24 hours. tempCol = ee.ImageCollection('NOAA/GFS0P25') \ .filterDate('2018-12-22', '2018-12-23') \ .limit(24) \ .select('temperature_2m_above_ground') # Define arguments for animation function parameters. videoArgs = { 'dimensions': 768, 'region': aoi, 'framesPerSecond': 10, 'crs': 'EPSG:3857', 'min': -40.0, 'max': 35.0, 'palette': ['blue', 'purple', 'cyan', 'green', 'yellow', 'red'] } # ### Save the GIF to local drive # In[ ]: saved_gif = os.path.join(os.path.expanduser('~'), 'Downloads/temperature.gif') geemap.download_ee_video(tempCol, videoArgs, saved_gif) # In[ ]: geemap.show_image(saved_gif) # ### Generate an hourly text sequence # In[ ]: text = [str(n).zfill(2) + ":00" for n in range(0, 24)] print(text) # ### Add text to GIF # In[ ]: out_gif = os.path.join(os.path.expanduser('~'), 'Downloads/output2.gif') # In[ ]: geemap.add_text_to_gif(saved_gif, out_gif, xy=('3%', '5%'), text_sequence=text, font_size=30, font_color='#ffffff') # In[ ]: geemap.add_text_to_gif(out_gif, out_gif, xy=('32%', '92%'), text_sequence='NOAA GFS Hourly Temperature', font_color='white') # In[ ]: geemap.show_image(out_gif)