Kepler.gl Python Jupyter Widget

0.3.7 · active · verified Tue Apr 14

Kepler.gl is an open-source, high-performance geospatial analysis and visualization tool developed by Uber, designed to render large-scale interactive maps. The `keplergl` Python library provides a Jupyter widget to embed and interact with Kepler.gl maps within notebooks. While the Python package is currently at version 0.3.7 on PyPI, its underlying JavaScript core (`kepler.gl`) is actively developed with v3.x releases, and a 0.4.0rc1 pre-release for the Python binding is available, indicating a continuous and active development cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a Kepler.gl map and add a Pandas DataFrame. The map can then be displayed in a Jupyter environment or saved as an interactive HTML file. A Mapbox API key is often required for base map functionality.

import pandas as pd
from keplergl import KeplerGl
import os

# Create a sample DataFrame
data = {
    'lat': [34.0522, 36.1699, 39.9042],
    'lon': [-118.2437, -115.1398, 116.4074],
    'city': ['Los Angeles', 'Las Vegas', 'Beijing'],
    'value':
}
df = pd.DataFrame(data)

# Initialize Kepler.gl map
# An empty map is created by default. You can also pass data and config here.
# Ensure MAPBOX_API_KEY is set as an environment variable for full basemap functionality.
# For example: os.environ['MAPBOX_API_KEY'] = 'YOUR_MAPBOX_ACCESS_TOKEN'
MAPBOX_API_KEY = os.environ.get('MAPBOX_API_KEY', '') # Replace with your token if not set as env var

map_1 = KeplerGl(height=400)

# Add data to the map
map_1.add_data(data=df, name='cities_data')

# Display the map (in a Jupyter environment)
# map_1 # Uncomment this line in a Jupyter notebook to display the map

# Optionally, save the map to an HTML file
# map_1.save_to_html(file_name='my_keplergl_map.html', config=map_1.config)

view raw JSON →