【问题标题】:Animated GIF wih Annotations. Annoying Bar on the side带注释的 GIF 动画。旁边的烦人酒吧
【发布时间】:2021-10-03 18:38:09
【问题描述】:

我编写了一个脚本,它使用 Google 地球引擎将一系列图像下载到 GIF 文件中,并将图像的日期作为注释放在上面。请看下面的代码:

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)




到目前为止一切正常。只有输出的 GIF 在右侧有一个恼人的条,它随着 GIF 的每一帧而变化。见下图:

关于如何解决这个问题的任何想法?

提前谢谢你!

【问题讨论】:

    标签: python geopandas google-earth-engine geemap


    【解决方案1】:

    我为我最初的问题找到了解决方案:

    我将用作“区域”的矩形变小,以更好地适应我想要覆盖的形状的大小。

    【讨论】:

      猜你喜欢
      • 2012-05-06
      • 1970-01-01
      • 1970-01-01
      • 2014-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-04
      相关资源
      最近更新 更多