Skip to content

Commit

Permalink
Add lonboard notebook example
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Nov 6, 2023
1 parent c38a54d commit 514a837
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 13 deletions.
6 changes: 0 additions & 6 deletions docs/notebooks/82_pmtiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
{
"cell_type": "markdown",
"id": "6f3406c5",
"metadata": {},
"source": [
"## Remote PMTiles\n",
Expand Down Expand Up @@ -107,7 +106,6 @@
},
{
"cell_type": "markdown",
"id": "e1166262",
"metadata": {},
"source": [
"### Overture data"
Expand Down Expand Up @@ -203,7 +201,6 @@
},
{
"cell_type": "markdown",
"id": "6b9d11d9",
"metadata": {},
"source": [
"### Source Cooperative\n",
Expand All @@ -214,7 +211,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9c6d5f2c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -227,7 +223,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2c2cfcf8",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -268,7 +263,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "789cce99",
"metadata": {},
"outputs": [],
"source": [
Expand Down
156 changes: 156 additions & 0 deletions docs/notebooks/83_vector_viz.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/83_vector_viz.ipynb)\n",
"[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/83_vector_viz.ipynb)\n",
"[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/83_vector_viz.ipynb&branch=master)\n",
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/01_leafmap_intro.ipynb)\n",
"[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder)\n",
"\n",
"**Visualizing large vector datasets with lonboard**\n",
"\n",
"This notebook demonstrates how to visualize large vector datasets with [lonboard](https://github.com/developmentseed/lonboard). Please note that lonboard does not support Visual Studio Code's interactive notebook yet. You will need to run this notebook in Jupyter Notebook or JupyterLab.\n",
"\n",
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# %pip install -U leafmap lonboard"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import leafmap.deckgl as leafmap\n",
"import geopandas as gpd"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Download sample datasets."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"url = \"https://open.gishub.org/data/duckdb/nyc_data.zip\"\n",
"leafmap.download_file(url, unzip=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create an interactive map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"m = leafmap.Map(center=[20, 0], zoom=1.2)\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add GeoDataFrame."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"streets = gpd.read_file('nyc_streets.shp')\n",
"m.add_gdf(streets, zoom_to_layer=True, pickable=True, get_width=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add any vector format supported by GeoPandas."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"m.add_vector('nyc_subway_stations.shp', get_radius=10, get_fill_color=[255, 0, 0, 180])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Change layer properties."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"m.layers[-1].get_fill_color = [0, 0, 255, 255]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.5"
}
},
"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 @@ -96,6 +96,7 @@
80. Visualizing solar radiation data from Google Solar API ([notebook](https://leafmap.org/notebooks/80_solar))
81. Downloading Microsoft and Google Building Footprints ([notebook](https://leafmap.org/notebooks/81_buildings))
82. Visualizing PMTiles with leafmap ([notebook](https://leafmap.org/notebooks/82_pmtiles))
83. Visualizing large vector datasets with lonboard ([notebook](https://leafmap.org/notebooks/83_vector_viz))

## Demo

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
80. Visualizing solar radiation data from Google Solar API ([notebook](https://leafmap.org/notebooks/80_solar))
81. Downloading Microsoft and Google Building Footprints ([notebook](https://leafmap.org/notebooks/81_buildings))
82. Visualizing PMTiles with leafmap ([notebook](https://leafmap.org/notebooks/82_pmtiles))
83. Visualizing large vector datasets with lonboard ([notebook](https://leafmap.org/notebooks/83_vector_viz))

## Demo

Expand Down
8 changes: 1 addition & 7 deletions examples/notebooks/82_pmtiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
{
"cell_type": "markdown",
"id": "6f3406c5",
"metadata": {},
"source": [
"## Remote PMTiles\n",
Expand Down Expand Up @@ -107,7 +106,6 @@
},
{
"cell_type": "markdown",
"id": "e1166262",
"metadata": {},
"source": [
"### Overture data"
Expand Down Expand Up @@ -203,7 +201,6 @@
},
{
"cell_type": "markdown",
"id": "6b9d11d9",
"metadata": {},
"source": [
"### Source Cooperative\n",
Expand All @@ -214,7 +211,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9c6d5f2c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -227,7 +223,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "2c2cfcf8",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -268,7 +263,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "789cce99",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -411,7 +405,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 514a837

Please sign in to comment.