我写了一个脚本,用Google Earth引擎下载一系列图像到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的每一帧而变化。如下图所示:

有什么办法解决这个问题吗?
提前谢谢你!
发布于 2021-09-08 16:03:44
我为我最初的问题找到了一个解决方案:
我把用作“区域”的矩形变得更小,以便更好地适应我想要覆盖的形状的大小。
https://stackoverflow.com/questions/68553310
复制相似问题