129 vector to gif
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:
- Uhl, Johannes H; Leyk, Stefan (2022), "MTBF-33: A multi-temporal building footprint dataset for 33 counties in the United States (1900–2015)", Data in Brief, 43, 108369. DOI: 10.1016/j.dib.2022.108369
- Uhl, Johannes H; Leyk, Stefan (2022), “MTBF-33: A multi-temporal building footprint dataset for 33 U.S. counties at annual resolution (1900-2015)”, Mendeley Data, V2. DOI: 10.17632/w33vbvjtdy.2
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install -U geemap
# !pip install -U geemap
In [ ]:
Copied!
import geemap
import geemap
In [ ]:
Copied!
# A subset of the dataset retrieved from https://github.com/johannesuhl/shapefile2gif
data = "https://github.com/giswqs/data/raw/main/us/boulder_buildings.zip"
# A subset of the dataset retrieved from https://github.com/johannesuhl/shapefile2gif
data = "https://github.com/giswqs/data/raw/main/us/boulder_buildings.zip"
In [ ]:
Copied!
m = geemap.Map(center=[39.9898, -105.2532], zoom=14)
m.add_vector(data, layer_name="Buildings")
m
m = geemap.Map(center=[39.9898, -105.2532], zoom=14)
m.add_vector(data, layer_name="Buildings")
m
In [ ]:
Copied!
out_gif = "buildings.gif"
colname = "year_built"
title = "Building Evolution in Boulder, Colorado, USA (1950-2015)"
out_gif = "buildings.gif"
colname = "year_built"
title = "Building Evolution in Boulder, Colorado, USA (1950-2015)"
In [ ]:
Copied!
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,
)
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,
)