Skip to content

Commit

Permalink
Added vector_to_gif function (#1348)
Browse files Browse the repository at this point in the history
* Change jupyterlab dependency to optional

* Added vector_to_gif function
  • Loading branch information
giswqs committed Nov 29, 2022
1 parent 4734f1d commit d196856
Show file tree
Hide file tree
Showing 6 changed files with 496 additions and 0 deletions.
123 changes: 123 additions & 0 deletions docs/notebooks/129_vector_to_gif.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "12102773",
"metadata": {},
"source": [
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/giswqs/geemap/blob/master/examples/notebooks/61_vector_to_gif.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/geemap-binder)\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.\n",
"\n",
"\n",
"Uncomment the following line to install [geemap](https://geemap.org) if needed."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3df89d34",
"metadata": {},
"outputs": [],
"source": [
"# !pip install -U geemap"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5821afaf",
"metadata": {},
"outputs": [],
"source": [
"import geemap"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17b0d275-56e9-470f-af27-8b9060905506",
"metadata": {},
"outputs": [],
"source": [
"data = 'https://github.com/giswqs/data/raw/main/us/boulder_buildings.zip'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fc635d81",
"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": "f0daeb77-42b0-4130-8d7b-3154c60aba35",
"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": "eac0fcdb-19c1-4547-be9b-c99829078114",
"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"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions docs/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ More video tutorials for geemap and Earth Engine are available on my [YouTube ch
126. Using the improved Inspector GUI ([notebook](https://geemap.org/notebooks/126_inspector))
127. Creating multiple legends and add them to the map ([notebook](https://geemap.org/notebooks/127_create_legend))
128. Adding text, images, HTML, and widgets to the map ([notebook](https://geemap.org/notebooks/128_add_widget))
129. Creating animated GIF from vector data with only one line of code ([notebook](https://geemap.org/notebooks/129_vector_to_gif))
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ More video tutorials for geemap and Earth Engine are available on my [YouTube ch
126. Using the improved Inspector GUI ([notebook](https://geemap.org/notebooks/126_inspector))
127. Creating multiple legends and add them to the map ([notebook](https://geemap.org/notebooks/127_create_legend))
128. Adding text, images, HTML, and widgets to the map ([notebook](https://geemap.org/notebooks/128_add_widget))
129. Creating animated GIF from vector data with only one line of code ([notebook](https://geemap.org/notebooks/129_vector_to_gif))

### 1. Introducing the geemap Python package for interactive mapping with Google Earth Engine

Expand Down
123 changes: 123 additions & 0 deletions examples/notebooks/129_vector_to_gif.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "12102773",
"metadata": {},
"source": [
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/giswqs/geemap/blob/master/examples/notebooks/61_vector_to_gif.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/geemap-binder)\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.\n",
"\n",
"\n",
"Uncomment the following line to install [geemap](https://geemap.org) if needed."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3df89d34",
"metadata": {},
"outputs": [],
"source": [
"# !pip install -U geemap"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5821afaf",
"metadata": {},
"outputs": [],
"source": [
"import geemap"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17b0d275-56e9-470f-af27-8b9060905506",
"metadata": {},
"outputs": [],
"source": [
"data = 'https://github.com/giswqs/data/raw/main/us/boulder_buildings.zip'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fc635d81",
"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": "f0daeb77-42b0-4130-8d7b-3154c60aba35",
"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": "eac0fcdb-19c1-4547-be9b-c99829078114",
"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"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit d196856

Please sign in to comment.