Spatial data visualization wizard keplergl

post thumb
Data Science
by Admin/ on 02 Jan 2022

Spatial data visualization wizard keplergl

We’d like to introduce you to an awesome spatial (geographic) data visualization tool: keplergl.

Keplergl is completely open source by Uber and is the default tool for spatial data visualization within Uber.

Through its open interface package keplergl for Python, we can pass in a variety of formats of data by writing Python code in jupyter notebook, and use its built-in rich spatial data visualization functions in its interactive window embedded in notebook. Here are 3 main addresses for learning.

  1. the official website address:

  2. jupyter notebook manual address:

  3. Case study address:


The installation of keplergl is very simple.

pip install keplergl

Amazing graphics

A wave of stunning graphics are coming.

post thumb post thumb post thumb post thumb post thumb post thumb post thumb post thumb post thumb

Getting Started

import pandas as pd
import geopandas as gpd

from keplergl import KeplerGl

# Create an object
kep1 = KeplerGl(height=600)
# Activate the object and load it into jupyter notebook

As you can see, after running the basic code in Jupyter directly generated the built-in graphics, the graphics themselves are also dynamic; dark black background is also my favorite:

post thumb

Adding data

By default, keplergl can add 3 types of data:

  1. csv
  2. GeoJSON
  3. DataFrame

csv format

There is a csv data in the local directory: china.csv, which records the latitude and longitude of each province in China.

with open("china.csv", "r") as f:
    csv_data =
# add_data add data
kep1.add_data(data=csv_data, name="csv_kep")
post thumb

DataFrame format

china = pd.read_csv("china.csv")
kep1.add_data(data=china, name="dataframe_kep")
post thumb

GeoJson format

url = ''
country_gdf = gpd.read_file(url) # geopandas read json file

kep1.add_data(data=country_gdf, name="state")
post thumb

Custom graphics

Keplergl’s customization method: the criticality button. Once inside, you can customize the operation

post thumb post thumb post thumb

Saving and reusing configurations

The configuration of the instantiated kep can be saved and reused in the following instance objects.

  1. Save.
# Save as a file
with open('','w') as f:
# Run: magic command %run
  1. Reuse
kep2 = KeplerGl(height=400,
                config=kep1.config # configuration of kep1

Save graphics

  1. minimalist version, mainly the file name
  1. full version: file name, configuration, data, readability
# 4 parameters

Web app

The operations shown above are all done in the notebook, we can also do them directly online:

We will share more articles after we have studied this tool seriously, this library is worth studying

post thumb post thumb


comments powered by Disqus