{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/gee-community/geemap/blob/master/examples/notebooks/129_vector_to_gif.ipynb)\n", "\n", "**Creating animated GIF from vector data**\n", "\n", "Inspired by Johannes Uhl's [shapefile2gif](https://github.com/johannesuhl/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](https://github.com/johannesuhl/shapefile2gif) repo. Credits to Johannes Uhl. For more information about the datasets, check out the references below: \n", "\n", "- Uhl, Johannes H; Leyk, Stefan (2022), \"MTBF-33: A multi-temporal building footprint dataset for\n", "33 counties in the United States (1900–2015)\", *Data in Brief*, 43, 108369. DOI: [10.1016/j.dib.2022.108369](https://doi.org/10.1016/j.dib.2022.108369)\n", "- Uhl, Johannes H; Leyk, Stefan (2022), “MTBF-33: A multi-temporal building footprint dataset for 33 U.S. counties\n", "at annual resolution (1900-2015)”, *Mendeley Data*, V2. DOI: [10.17632/w33vbvjtdy.2](https://doi.org/10.17632/w33vbvjtdy.2)\n", "\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "# !pip install -U geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "2", "metadata": {}, "outputs": [], "source": [ "import geemap" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "# A subset of the dataset retrieved from https://github.com/johannesuhl/shapefile2gif\n", "data = \"https://github.com/giswqs/data/raw/main/us/boulder_buildings.zip\"" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "m = geemap.Map(center=[39.9898, -105.2532], zoom=14)\n", "m.add_vector(data, layer_name=\"Buildings\")\n", "m" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "out_gif = \"buildings.gif\"\n", "colname = \"year_built\"\n", "title = \"Building Evolution in Boulder, Colorado, USA (1950-2015)\"" ] }, { "cell_type": "code", "execution_count": null, "id": "6", "metadata": {}, "outputs": [], "source": [ "geemap.vector_to_gif(\n", " data,\n", " out_gif,\n", " colname,\n", " vmin=1950,\n", " vmax=2015,\n", " step=10,\n", " facecolor=\"black\",\n", " figsize=(10, 8),\n", " title=title,\n", " xy=(\"1%\", \"1%\"),\n", " fontsize=20,\n", " progress_bar_color=\"blue\",\n", " progress_bar_height=10,\n", " dpi=300,\n", " fps=10,\n", " mp4=False,\n", " verbose=True,\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }