import geemap
geemap.set_proxy(port=10809)
geemap.show_youtube('OwjSJnGWKJs')
import ee
import geemap
geemap.set_proxy(port=10809)
Map = geemap.Map(center=(38, 105))
Map
hf_shp ="G:/Rdata/Anhui/hefei.shp"
hf_ee = geemap.shp_to_ee(qs_shp)
hf_ee_geo = ee.FeatureCollection(hf_ee).geometry()
collection = geemap.landsat_timeseries(roi = hf_ee_geo , start_year=1985, end_year=2021, start_date='06-10', end_date='09-20')
print(collection.size().getInfo())
Mean_image = collection.mean()
vis = {
'bands': ['NIR', 'Red', 'Green'],
'min': 0,
'max': 4000,
'gamma': [1, 1, 1]
}
Map.addLayer(Mean_image, vis, 'Mean image')
# define arguments for animation function parameters
video_args = {
'dimensions': 768,
'region': hf_ee_geo,
'framesPerSecond': 3,
'bands': ['Red', 'Green', 'Red'],
'min': 0,
'max': 4000,
'gamma': [1, 1, 1]
}
work_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
if not os.path.exists(work_dir):
os.makedirs(work_dir)
out_gif = os.path.join(work_dir, "hf_landsat_ts.gif")
geemap.download_ee_video(collection, video_args, out_gif)
geemap.show_image(out_gif)
往GIF上添加文本及图像
1.添加时间和进度条
texted_gif = os.path.join(work_dir, "hf_landsat_text_ts.gif")
geemap.add_text_to_gif(out_gif, texted_gif, xy=('3%', '5%'), text_sequence=1985, font_size=30, font_color='#ffffff', add_progress_bar=True, progress_bar_color='white', duration = 300)
2.添加标题
label = 'Urban Growth in HeiFei'
geemap.add_text_to_gif(texted_gif, texted_gif, xy=('2%', '95%'),text_sequence=label, font_size=20, font_color='#ffffff', duration = 300)
geemap.show_image(texted_gif)
3.添加图像
hf_logo = 'https://imusae-static.90sheji.com/imusae/static/wordart/2020/12/15/dd312a433c4197730d7435bc665b5c17.png'
geemap.add_image_to_gif(texted_gif, texted_gif, in_image=hf_logo, xy=('85%','2%'), image_size=(80, 80))
geemap.show_image(texted_gif)
成图: