Skip to content

83 vector viz

image image image

Visualizing large vector datasets with lonboard

This notebook demonstrates how to visualize large vector datasets with 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.

Uncomment the following line to install leafmap if needed.

1
# %pip install -U leafmap lonboard
1
2
3
import leafmap.deckgl as leafmap
import geopandas as gpd
import ipywidgets as widgets

Download sample datasets.

1
2
url = "https://opengeos.org/data/duckdb/nyc_data.zip"
leafmap.download_file(url, unzip=True)

Create an interactive map.

1
2
m = leafmap.Map(center=[20, 0], zoom=1.2)
m

Add GeoDataFrame.

1
2
streets = gpd.read_file("nyc_streets.shp")
m.add_gdf(streets, zoom_to_layer=True, pickable=True, get_width=5)

Add any vector format supported by GeoPandas.

1
m.add_vector("nyc_subway_stations.shp", get_radius=10, get_fill_color=[255, 0, 0, 180])

Change layer properties.

1
2
layer = m.layers[-1]
layer.get_fill_color = [0, 0, 255, 255]

Interactive widgets.

1
2
3
color = widgets.ColorPicker(value="red", description="Color")
width = widgets.IntSlider(min=1, max=100, value=10, description="Radius")
hbox = widgets.HBox([color, width])
1
2
widgets.dlink((color, "value"), (layer, "get_fill_color"))
widgets.dlink((width, "value"), (layer, "get_radius"))
1
hbox
1
m