kepler.gl
kepler.gl is not a charting library you configure in code – it’s a complete map-authoring application: drop in data and it auto-creates layers, then a side panel lets anyone add more layers, switch a layer to 3D hexbins or arcs, build filters, scrub a time window and play it back, and restyle the basemap, with no code. @render_keplergl accepts a pandas.DataFrame, a geopandas.GeoDataFrame, or a keplergl.KeplerGl widget (for multiple datasets or a starting config), and its one accessor, config(), reads back whatever the user builds.

kepler.gl auto-creates a colored point layer from Montreal car-share station data – no config needed. Try the app.
Installation
pip install 'shinywidgets[keplergl]'This installs keplergl, plus geopandas, pyarrow, shapely, and pyproj, which kepler.gl’s own serializer needs even for plain-DataFrame input.
Quick start
Return a DataFrame with recognizable latitude/longitude column names (lat/latitude, lon/lng/longitude) and kepler.gl auto-creates a colored point layer:
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_keplergl
# Montreal car-share station activity: average hours in use per car, and
# the most common peak hour, at 249 stations
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
ui.page_opts(title="kepler.gl in Shiny", fillable=True)
@render_keplergl
def map():
return carshare
Open the side panel (the > arrow, top left) and every layer, filter, and basemap control is right there – no extra code.
Overview
A look at what you can build. Click any of them to open the app, with its code, in Shinylive.
3D hexbins, authored in Python
A draggable time window, with playback
Read the live camera from config()
Rate-limit config() during playback
Swap data in place, keep the camera
Save a view, restore it later
A time window drives a live table
One input, two linked views
A 3D bird-migration dashboard
A clean starting template
Map features
3D hexbins from Python
Pass a KeplerGl widget with a config instead of a bare DataFrame to skip the side-panel authoring step and open directly on a styled, aggregated view. A hexagon layer with enable3d turns point density into a 3D bar chart on the map:
import plotly.express as px
from keplergl import KeplerGl
from shiny.express import ui
from shinywidgets import render_keplergl
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
# A hand-written kepler.gl config: one 3D hexbin layer, colored and sized by
# average car-share hours per hexagon. Writing config upfront, rather than
# setting `.widget.config` after render, avoids a duplicate auto-created
# layer (see Gotchas & limitations).
CONFIG = {
"version": "v1",
"config": {
"visState": {
"layers": [
{
"id": "carshare-hex",
"type": "hexagon",
"config": {
"dataId": "data",
"label": "Car-share activity",
"columns": {"lat": "lat", "lng": "lon"},
"isVisible": True,
"visConfig": {
"worldUnitSize": 0.5,
"resolution": 8,
"colorRange": {
"name": "Global Warming",
"type": "sequential",
"category": "Uber",
"colors": [
"#4C0035",
"#880030",
"#B72F15",
"#D6610A",
"#EF9100",
"#FFC300",
],
},
"coverage": 0.9,
"elevationScale": 15,
"enable3d": True,
},
},
"visualChannels": {
"colorField": {"name": "car_hours", "type": "real"},
"colorScale": "quantile",
"sizeField": {"name": "car_hours", "type": "real"},
"sizeScale": "linear",
},
}
],
},
"mapState": {
"latitude": 45.53,
"longitude": -73.626,
"zoom": 11.2,
"pitch": 50,
"bearing": -15,
},
},
}
ui.page_opts(title="3D hexbin via config", fillable=True)
@render_keplergl
def map():
return KeplerGl(data={"data": carshare}, config=CONFIG)
kepler.gl’s config schema is large but mostly optional – every key you omit falls back to a sensible default. The easiest way to get a starting config is to build one in the UI once and read it back with .config() (see Linking widgets).
GeoDataFrame input
A GeoDataFrame works exactly like a plain DataFrame, as long as it’s in EPSG:4326 (longitude/latitude degrees) – kepler.gl does not reproject, so a GeoDataFrame in any other CRS renders silently in the wrong place.
import geopandas as gpd
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_keplergl
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
# A GeoDataFrame works the same way as a plain DataFrame, as long as it's in
# EPSG:4326 (longitude/latitude degrees). kepler.gl doesn't reproject: a
# GeoDataFrame in any other CRS renders in the wrong place with no error.
stations = gpd.GeoDataFrame(
carshare,
geometry=gpd.points_from_xy(carshare.lon, carshare.lat),
crs="EPSG:4326",
)
ui.page_opts(title="GeoDataFrame input", fillable=True)
@render_keplergl
def map():
return stations
Time filter and playback
Add a timeRange filter to the config and kepler.gl draws a histogram + draggable window + play button at the bottom of the map. This is the single most distinctive kepler.gl feature: the window (and its playback) lives entirely in the widget’s config, so Python can read exactly what’s visible at any moment (see Linking widgets).
import pandas as pd
from keplergl import KeplerGl
from shiny.express import ui
from shinywidgets import render_keplergl
# A full year (2015) of daily positions for ten tracked bird species migrating
# between South America and the Arctic (vega-datasets' "bird-migration", also
# one of kepler.gl's own demo datasets). kepler.gl needs a real timestamp dtype
# (not a date string) to offer a time filter.
birds = pd.read_csv("https://cdn.jsdelivr.net/gh/vega/vega-datasets@5448e25297c8f705be78e879d5423d55d04dc6f1/data/bird-migration.csv")
birds["date"] = pd.to_datetime(birds["date"])
# A timeRange filter adds the histogram + play button at the bottom of the
# map. The initial window (in epoch milliseconds) spotlights one week in
# April, mid-way through the northward spring migration.
CONFIG = {
"version": "v1",
"config": {
"visState": {
"filters": [
{
"dataId": ["data"],
"id": "migration-date-window",
"name": ["date"],
"type": "timeRange",
"value": [1_427_846_400_000, 1_428_451_200_000],
"plotType": {"type": "histogram", "interval": "1-day"},
"animationWindow": "free",
"view": "enlarged",
"speed": 1,
"enabled": True,
}
],
},
"mapState": {
"latitude": 25.0,
"longitude": -85.0,
"zoom": 3.5,
},
},
}
ui.page_opts(title="Time filter and playback", fillable=True)
@render_keplergl
def map():
return KeplerGl(data={"data": birds}, config=CONFIG)
Timestamps need to be a real datetime dtype (not a date string): kepler.gl’s field-type detection only recognizes a timeRange-filterable column from an Arrow timestamp column, which use_arrow=True sends for any datetime64 column. A plain string column shows up as string, with no time filter available.
Reacting to interaction
kepler.gl’s one synced-back trait is the entire map config, and the config() accessor reads it. The accessor is opt-in – pass listen_to=["config"] to @render_keplergl – because kepler.gl syncs the whole config on every store dispatch: each animation frame of a pan or zoom, every filter drag, every frame of time-filter playback. With listen_to=["config"], map.config() reads it reactively, debounced (250 ms) by default – rate_policy/rate_delay adjust that (see Rate limiting). To read the trait without opting in per output, shinywidgets.config(native_events=True) opens the wire app-wide.
import plotly.express as px
from shiny.express import render, ui
from shinywidgets import render_keplergl
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
ui.page_opts(title="Reading kepler.gl's config", fillable=True)
with ui.layout_columns(col_widths=[8, 4]):
with ui.card(full_screen=True):
@render_keplergl(listen_to=["config"])
def map():
return carshare
with ui.card():
ui.card_header("Map view (from config.mapState)")
@render.code
def view_state():
config = map.config()
state = config.get("config", {}).get("mapState", {})
if not state:
return "Waiting for the map to load..."
return (
f"lat: {state['latitude']:.3f}\n"
f"lon: {state['longitude']:.3f}\n"
f"zoom: {state['zoom']:.2f}\n"
f"pitch: {state['pitch']:.0f}\n"
f"bearing: {state['bearing']:.0f}"
)

Updating in place
Every newly rendered KeplerGl widget ships kepler.gl’s full JavaScript bundle again. Re-returning a new value from the render function (even an unchanged one) re-renders the widget and resends that bundle, and it also discards any layers, colors, or filters the user built in kepler’s side panel, since those live only in the old (now-replaced) widget instance.
Updating .widget.data in place avoids both costs: it sends the new data without the bundle, keeps the same widget mounted in the browser, and preserves the user’s styling, layers, filters, and camera position. Each update still sends the full replacement dataset, so its cost grows with the data.
import plotly.express as px
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_keplergl
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
ui.page_opts(title="Updating data in place", fillable=True)
ui.input_slider("min_hours", "Minimum car-share hours", 0, 3000, 0, step=100)
def filtered():
return carshare[carshare["car_hours"] >= input.min_hours()]
@render_keplergl
def map():
# Read the input under isolate(): this render function only runs once
# (on first display). The effect below keeps the data current.
with reactive.isolate():
return filtered()
@reactive.effect
@reactive.event(input.min_hours)
def _():
# Swapping `.widget.data` in place sends only the new rows (kilobytes),
# keeps the map mounted, and preserves any layer/filter/camera changes
# the user made in kepler's side panel. Re-returning a new value from
# `map()` instead would re-send kepler's ~13 MB bundle and reset the UI.
map.widget.data = {"data": filtered()}

Use in-place updates for anything driven by a Shiny input (filters, a different dataset slice, a live feed). Re-render only when the number or identity of datasets changes in a way that’s easier to express as a fresh KeplerGl(...) call than as a .data = / .add_data() update, or when you want to deliberately reset the user’s styling.
Save and restore a view
Because the entire authored state – camera, layers, colors, filters – lives in one config dict, map.config() is a complete, serializable snapshot of whatever a user built. Store it, and .widget.config = saved reproduces it exactly, including on a widget that has since been reset or moved elsewhere:
import plotly.express as px
from keplergl import KeplerGl
from shiny import reactive
from shiny.express import input, render, ui
from shinywidgets import render_keplergl
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
DEFAULT_CONFIG = {
"version": "v1",
"config": {"mapState": {"latitude": 45.53, "longitude": -73.6, "zoom": 10}},
}
saved_config = reactive.value(None)
ui.page_opts(title="Saving and restoring a view", fillable=True)
with ui.layout_columns(col_widths=[8, 4]):
with ui.card(full_screen=True):
@render_keplergl(listen_to=["config"])
def map():
return KeplerGl(data={"data": carshare}, config=DEFAULT_CONFIG)
with ui.card():
ui.input_action_button("save", "Save current view")
ui.input_action_button("reset", "Reset to default")
ui.input_action_button("restore", "Restore saved view")
@render.code
def saved_view():
cfg = saved_config.get()
if cfg is None:
return "No view saved yet."
state = cfg.get("config", {}).get("mapState", {})
return (
f"saved zoom: {state.get('zoom', 0):.2f}, "
f"lat: {state.get('latitude', 0):.3f}"
)
# The whole config -- not just mapState -- round-trips, so this also
# preserves any layers, colors, or filters the user set up in kepler's UI.
@reactive.effect
@reactive.event(input.save)
def _():
saved_config.set(map.config())
@reactive.effect
@reactive.event(input.reset)
def _():
map.widget.config = DEFAULT_CONFIG
@reactive.effect
@reactive.event(input.restore)
def _():
if saved_config.get() is not None:
map.widget.config = saved_config.get()


This is the pattern to reach for whenever a user should be able to “save this view” (a bookmark, a report snapshot, a default for next time): persist the dict (it’s plain JSON) anywhere Shiny can read it back – a database row, a file, another user’s session.
Linking widgets
Time window drives a table
Read the active timeRange filter’s value and filter your own copy of the data by it, for a table (or any other output) that always matches exactly what the map is currently showing – including live, frame by frame, during playback.
import pandas as pd
from keplergl import KeplerGl
from shiny.express import render, ui
from shinywidgets import render_keplergl
birds = pd.read_csv("https://cdn.jsdelivr.net/gh/vega/vega-datasets@5448e25297c8f705be78e879d5423d55d04dc6f1/data/bird-migration.csv")
birds["date"] = pd.to_datetime(birds["date"])
CONFIG = {
"version": "v1",
"config": {
"visState": {
"filters": [
{
"dataId": ["data"],
"id": "migration-date-window",
"name": ["date"],
"type": "timeRange",
"value": [1_427_846_400_000, 1_428_451_200_000],
"plotType": {"type": "histogram", "interval": "1-day"},
"animationWindow": "free",
"view": "enlarged",
"speed": 1,
"enabled": True,
}
],
},
"mapState": {
"latitude": 25.0,
"longitude": -85.0,
"zoom": 3.5,
},
},
}
ui.page_opts(title="Time window drives a detail table", fillable=True)
with ui.layout_columns(col_widths=[7, 5]):
with ui.card(full_screen=True):
@render_keplergl(listen_to=["config"], rate_policy="throttle", rate_delay=0.5)
def map():
return KeplerGl(data={"data": birds}, config=CONFIG)
with ui.card(full_screen=True):
ui.card_header("Birds in the current time window")
@render.data_frame
def visible_rows():
config = map.config()
filters = config.get("config", {}).get("visState", {}).get("filters", [])
if not filters:
return birds.iloc[0:0]
start_ms, end_ms = filters[0]["value"]
start, end = pd.to_datetime(start_ms, unit="ms"), pd.to_datetime(end_ms, unit="ms")
window = birds[birds["date"].between(start, end)]
return render.DataGrid(
window[["species", "date", "lat", "lon"]],
height="100%",
)

One input, two linked views
A single Shiny input can drive the map (in place) and a companion chart from the same filtered data, so they never disagree:
import plotly.express as px
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_keplergl, render_plotly
carshare = px.data.carshare().rename(
columns={"centroid_lat": "lat", "centroid_lon": "lon"}
)
ui.page_opts(title="One input, two linked views", fillable=True)
ui.input_slider("min_hours", "Minimum car-share hours", 0, 3000, 0, step=100)
def filtered():
return carshare[carshare["car_hours"] >= input.min_hours()]
with ui.layout_columns(col_widths=[7, 5]):
with ui.card(full_screen=True):
@render_keplergl
def map():
with reactive.isolate():
return filtered()
with ui.card(full_screen=True):
@render_plotly
def hist():
fig = px.histogram(filtered(), x="car_hours", nbins=20)
fig.update_layout(
title=f"{len(filtered())} stations", margin=dict(t=40)
)
return fig
@reactive.effect
@reactive.event(input.min_hours)
def _():
# Both views come from the same `filtered()` call: the map updates in
# place (preserving its camera and any styling), and the histogram
# re-renders -- cheap, since it's an ordinary plotly figure.
map.widget.data = {"data": filtered()}
Accessor reference
| Accessor | Returns | Before any interaction | Across re-render | Default rate policy |
|---|---|---|---|---|
config() |
dict – the whole kepler.gl config (mapState, visState.layers, visState.filters, …) |
{}, until the map has loaded |
Reset to the render function’s own config (a fresh widget discards whatever the user had built) | Debounced, 250 ms |
config()
config is the trait worth reading. height also changes (the browser writes the measured size into it; see Layout and sizing), but data, mapbox_token, theme, and app_name are Python-to-browser only – kepler.gl’s bundled JS never writes them back.
config is {} until the map has loaded, so guard for that. Once populated, the useful parts are:
| Path | What it holds |
|---|---|
config["mapState"] |
latitude, longitude, zoom, pitch, bearing – updates on every pan, zoom, tilt, or rotate |
config["visState"]["layers"] |
Every layer’s type, columns, color/size encodings, and isVisible – updates when the user adds, edits, or toggles a layer in the side panel |
config["visState"]["filters"] |
Each filter’s current value (a [start, end] pair in epoch ms for a timeRange filter) – updates on every drag and on every animation frame during playback |
Tuning accessors
Rate limiting
config rewrites on close to every animation frame during time-filter playback – dozens of invalidations a second with no rate limit, against a widget whose view only needs to update a couple of times a second. The config() accessor debounces (250 ms) by default; render_keplergl’s rate_policy and rate_delay kwargs override that (here, a throttle to at most one read per 0.5 s):
import pandas as pd
from keplergl import KeplerGl
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_keplergl
birds = pd.read_csv("https://cdn.jsdelivr.net/gh/vega/vega-datasets@5448e25297c8f705be78e879d5423d55d04dc6f1/data/bird-migration.csv")
birds["date"] = pd.to_datetime(birds["date"])
CONFIG = {
"version": "v1",
"config": {
"visState": {
"filters": [
{
"dataId": ["data"],
"id": "migration-date-window",
"name": ["date"],
"type": "timeRange",
"value": [1_427_846_400_000, 1_428_451_200_000],
"plotType": {"type": "histogram", "interval": "1-day"},
"animationWindow": "free",
"view": "enlarged",
"speed": 1,
"enabled": True,
}
],
},
"mapState": {
"latitude": 25.0,
"longitude": -85.0,
"zoom": 3.5,
},
},
}
ui.page_opts(title="Rate-limiting config()", fillable=True)
with ui.layout_columns(col_widths=[8, 4]):
with ui.card(full_screen=True):
# `config` rewrites on almost every animation frame during playback.
# The accessor debounces by default; this throttle goes further.
@render_keplergl(listen_to=["config"], rate_policy="throttle", rate_delay=0.5)
def map():
return KeplerGl(data={"data": birds}, config=CONFIG)
with ui.card():
ui.card_header("config() invocations (throttled to 2/s)")
count = reactive.value(0)
@reactive.effect
def _():
map.config()
with reactive.isolate():
count.set(count.get() + 1)
@render.code
def n():
return f"reads so far: {count.get()}"

Reach for an explicit rate policy whenever a downstream calculation driven by map.config() is non-trivial (a DataFrame filter, a database query, another render) and the map has a time filter, or when users are likely to drag the map around a lot. For a cheap read like the mapState printout above, the default debounce is fine.
Large data
kepler.gl uses deck.gl’s GPU aggregation layers (hexbin, grid, cluster) for large-scale geospatial data – the same engine lonboard uses, the GPU-in-browser approach. That GPU rendering doesn’t change what crosses the wire, though: the full dataset still goes to the browser, and only the aggregation happens client-side. This guide doesn’t give a specific row-count ceiling; see kepler.gl’s own docs for upstream guidance. For per-gesture accessors and the lightest payload at real scale, prefer lonboard instead – kepler.gl trades that for its point-and-click authoring UI. See the Large data & performance article for the general comparison.
Layout and sizing
In a filling layout (ui.card(full_screen=True), a sidebar, page_opts(fillable=True)), the map resizes to its container the same way every shinywidgets output does. The one kepler-specific wrinkle: the browser (not Python) ends up owning the widget’s height trait once the output is sizing the map, because kepler.gl’s own React state reads height from the model, so a ResizeObserver writes the measured pixel height back into it. Don’t set .widget.height from Python while the output is filling or has an explicit height – change the output’s size (output_widget(height=...) in Core mode, or the surrounding card/sidebar) instead. KeplerGl(height=400) is indistinguishable from the library’s own default and so still fills; pass a different height to opt out, or size the output explicitly.
Fill, cards, full_screen, hidden tabs, and explicit pixel/vh/% heights all size the map correctly.
Gotchas
- kepler.gl assumes EPSG:4326 (WGS84 lon/lat) and does not reproject; a GeoDataFrame in a projected CRS (e.g. EPSG:3857) renders silently in the wrong place. Reproject with
.to_crs(4326)first. - A returned DataFrame/GeoDataFrame becomes a dataset named
"data"; use that as thedataIdin any hand-writtenconfig. - A config-set containing an explicit
layersentry breaks on keplergl 0.4.0: the layer stops rendering, and a saved time window can’t be restored programmatically. StripvisState.layersfrom a saved config before assigning it; camera-only restore still works, as the gallery showcase does. - Every freshly rendered
KeplerGlwidget ships kepler.gl’s full JavaScript bundle again, which is why Updating in place matters more here than for most widgets.
Learn more
- kepler.gl user guide
- kepler.gl on GitHub
- GPU-scale rendering driven entirely from Python: lonboard
- A styled vector-tile basemap with code-driven restyling: maplibre
- Per-feature click/hover callbacks with a simpler API: ipyleaflet, leafmap
- The linked-chart pattern used above: plotly