Katerkaskade
Katerkaskade

Reputation: 11

Animated GIF wih Annotations. Annoying Bar on the side

I wrote a script that downloads a series of images with Google Earth Engine into a GIF-File and puts the Date of the image as annotation on it. See the code below:

import geopandas as gpd
import ee
import os
import geemap

from datetime import date, timedelta
# ee.Authenticate()
ee.Initialize()

rect = ee.Geometry.Polygon(
  [[[-269.6484375, 77.9156690],
    [-269.6484375, 46.0122238],
    [-168.8378906, 46.0122238],
    [-168.8378906, 77.9156690]]],
)

collection = ee.ImageCollection("MODIS/006/MOD13Q1")\
  .filterDate('2020-01-01', '2020-12-31')\
  .select('NDVI')

sdate = date(2020, 1, 1)   # start date
edate = date(2020, 12, 18)   # end date
date_modified = sdate
datelist = [sdate]

while date_modified < edate:
    date_modified += timedelta(days=16)
    datelist.append(date_modified)

print(list)

mask = gpd.read_file('Data/RUS_adm1.shp')

im = ee.Image(collection.first().clip(mask))

args = {'dimensions': 600,
        'crs': 'EPSG:3857',
        'region': rect,
        'min': 0,
        'max': 10000,
        'palette': ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601',
                    '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301'],
        'framesPerSecond': 1}


print(collection.select('NDVI').sort('system:time_start', True).getVideoThumbURL(args))
# print((collection,args))

saved_gif = os.path.join(os.path.expanduser('~'), 'Downloads/NDVI.gif')
geemap.download_ee_video(collection, args, saved_gif)

out_gif = os.path.join(os.path.expanduser('~'), 'Downloads/NDVI.gif')

geemap.add_text_to_gif(saved_gif, out_gif, xy=('10%', '5%'), text_sequence=datelist, font_size=30, font_color='#ffffff',
                       duration=250, add_progress_bar=False)
geemap.add_text_to_gif(out_gif, out_gif, xy=('50%', '5%'), text_sequence='16 Day NDVI for the year 2020', 
                       font_color='white', duration=250, add_progress_bar=False)
geemap.show_image(out_gif)




Everything works fine so far. Only the output GIF has an annoying bar on the right side which changes with every frame of the GIF. See picture below: Sample frame of the output GIF

Any ideas on how to fix this?

Thank you in advance!

Upvotes: 0

Views: 133

Answers (1)

Katerkaskade
Katerkaskade

Reputation: 11

I found a solution for my initial question:

I made the rectangle that served as "region" smaller to better fit to the size of the shape I wanted to cover.

Upvotes: 0

Related Questions