Creating animated GIF from vector data
Inspired by Johannes Uhl's shapefile2gif, I created a vector_to_gif()
function in geemap that makes it much easier to create animated GIF from vector data with only one line of code. The sample dataset used in this notebook is a subset of the dataset retrieved from the shapefile2gif repo. Credits to Johannes Uhl. For more information about the datasets, check out the references below:
33 counties in the United States (1900–2015)", Data in Brief, 43, 108369. DOI: 10.1016/j.dib.2022.108369
at annual resolution (1900-2015)”, Mendeley Data, V2. DOI: 10.17632/w33vbvjtdy.2
Uncomment the following line to install geemap if needed.
# !pip install -U geemap
import geemap
# A subset of the dataset retrieved from https://github.com/johannesuhl/shapefile2gif
data = "https://github.com/giswqs/data/raw/main/us/boulder_buildings.zip"
m = geemap.Map(center=[39.9898, -105.2532], zoom=14)
m.add_vector(data, layer_name="Buildings")
m
out_gif = "buildings.gif"
colname = "year_built"
title = "Building Evolution in Boulder, Colorado, USA (1950-2015)"
geemap.vector_to_gif(
data,
out_gif,
colname,
vmin=1950,
vmax=2015,
step=10,
facecolor="black",
figsize=(10, 8),
title=title,
xy=("1%", "1%"),
fontsize=20,
progress_bar_color="blue",
progress_bar_height=10,
dpi=300,
fps=10,
mp4=False,
verbose=True,
)