17 add colorbar to gif
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install geemap
# !pip install geemap
In [ ]:
Copied!
import geemap
import os
import geemap
import os
In [ ]:
Copied!
# geemap.update_package()
# geemap.update_package()
Download a GIF¶
In [ ]:
Copied!
from geemap import *
from geemap import *
In [ ]:
Copied!
url = 'https://i.imgur.com/MSde1om.gif'
out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
download_from_url(url, out_file_name='temp.gif', out_dir=out_dir)
url = 'https://i.imgur.com/MSde1om.gif'
out_dir = os.path.join(os.path.expanduser('~'), 'Downloads')
if not os.path.exists(out_dir):
os.makedirs(out_dir)
download_from_url(url, out_file_name='temp.gif', out_dir=out_dir)
In [ ]:
Copied!
in_gif = os.path.join(out_dir, 'temp.gif')
show_image(in_gif)
in_gif = os.path.join(out_dir, 'temp.gif')
show_image(in_gif)
Get image URLs¶
In [ ]:
Copied!
noaa_logo = 'https://bit.ly/3ahJoMq'
ee_logo = 'https://i.imgur.com/Qbvacvm.png'
noaa_logo = 'https://bit.ly/3ahJoMq'
ee_logo = 'https://i.imgur.com/Qbvacvm.png'
Set output GIF path¶
In [ ]:
Copied!
out_gif = os.path.join(out_dir, 'output.gif')
out_gif = os.path.join(out_dir, 'output.gif')
Add images to GIF¶
In [ ]:
Copied!
add_image_to_gif(
in_gif, out_gif, in_image=noaa_logo, xy=('2%', '80%'), image_size=(80, 80)
)
add_image_to_gif(
in_gif, out_gif, in_image=noaa_logo, xy=('2%', '80%'), image_size=(80, 80)
)
In [ ]:
Copied!
add_image_to_gif(
out_gif, out_gif, in_image=ee_logo, xy=('13%', '79%'), image_size=(85, 85)
)
add_image_to_gif(
out_gif, out_gif, in_image=ee_logo, xy=('13%', '79%'), image_size=(85, 85)
)
Display output GIF¶
In [ ]:
Copied!
show_image(out_gif)
show_image(out_gif)
Create a colorbar¶
In [ ]:
Copied!
width = 250
height = 30
palette = ['blue', 'purple', 'cyan', 'green', 'yellow', 'red']
labels = [-40, 35]
colorbar = create_colorbar(
width=width,
height=height,
palette=palette,
vertical=False,
add_labels=True,
font_size=20,
labels=labels,
)
width = 250
height = 30
palette = ['blue', 'purple', 'cyan', 'green', 'yellow', 'red']
labels = [-40, 35]
colorbar = create_colorbar(
width=width,
height=height,
palette=palette,
vertical=False,
add_labels=True,
font_size=20,
labels=labels,
)
In [ ]:
Copied!
show_image(colorbar)
show_image(colorbar)
Add colorbar to GIF¶
In [ ]:
Copied!
add_image_to_gif(
out_gif, out_gif, in_image=colorbar, xy=('69%', '89%'), image_size=(250, 250)
)
add_image_to_gif(
out_gif, out_gif, in_image=colorbar, xy=('69%', '89%'), image_size=(250, 250)
)
In [ ]:
Copied!
show_image(out_gif)
show_image(out_gif)
Last update:
2023-04-06
Created: 2020-04-16
Created: 2020-04-16