Skip to content

Latest commit

 

History

History
 
 

kepler.gl-jupyter

kepler.gl for Jupyter

This is the kepler.gl jupyter widget, an advanced geospatial visualization tool, to render large-scale interactive maps in Jupyter Notebook.

Kepler.gl for Jupyter

Table of contacts

Installation

Prerequisites

  • Python >= 2
  • ipywidgets >= 7.0.0

To install use pip:

$ pip install keplergl

If you on Mac used pip install and running Notebook 5.3 and above, you don't need to run the following

$ jupyter nbextension install --py --sys-prefix keplergl # can be skipped for notebook 5.3 and above

$ jupyter nbextension enable --py --sys-prefix keplergl # can be skipped for notebook 5.3 and above

If you are in JupyterLab, you will also need to install the JupyterLab extension. This require node > 8.15.0

If you use Homebrew on Mac:

$ brew install node@8

Then install jupyter labextension.

$ jupyter labextension install @jupyter-widgets/jupyterlab-manager keplergl-jupyter

Prerequisites for JupyterLab:

  • Node > 8.15.0
  • Python 3
  • JupyterLab >=1.0.0 || >=2.0.0

Quick Start

# Load kepler.gl with an empty map
from keplergl import KeplerGl
map_1 = KeplerGl(height=400)
map_1

# Load kepler.gl with map data and config
map_2 = KeplerGl(height=400, data={'data_1': df}, config=config)
map_2

# Add data to map
map_1.add_data(df, 'data_1')

# Apply config
map_1.config(config)

# print data and config
map_1.data
map_1.config

# save map to html
map_1.save_to_html(file_name='keplergl_map.html')

Demo Notebooks

https://docs.kepler.gl/docs/keplergl-jupyter#1-load-keplergl-map

Usage

Local Development Setup

Environment Setup

You will need to install node, yarn and Jupyter Notebook.

1. Node and Yarn

Install node > 10.15.0, and yarn. Use nvm for better node version management e.g. nvm install 10.

2. Install Jupyter with pip

Python 3

$ python3 -m pip install --upgrade pip
$ python3 -m pip install jupyter

Python 2

$ python -m pip install --upgrade pip
$ python -m pip install jupyter

Download and run keplergl in your local Jupyter Notebook

Clone Repo

$ git clone https://github.com/keplergl/kepler.gl.git

Setup JS

1. Install Js module

    $ cd bindings/kepler.gl-jupyter
    $ cd js
    $ yarn

2. Load mapbox token

Add Mapbox access token to Node env.

export MapboxAccessTokenJupyter=<your_mapbox_token>

3. Build js module, start a local server to watch for changes

$ npm start

You need to run step 2 and 3 to restart the js program. And step 1-3 if any js dependency has changed (Usually after pulling new changes from master).

Setup jupyter

1. Install python module and enable extension from local files

This command must be run AFTER the js setup, and folder static/ was created. It only needs to be run once.

    # dev install from folder containing setup.py
    $ pip install -e .

    # only needed in dev mode, not in normal mode.
    $ jupyter nbextension install --py --symlink --sys-prefix keplergl

    # only needed in dev mode, not in normal mode.
    $ jupyter nbextension enable --py --sys-prefix keplergl

2. Start jupyter notebook

$ cd notebooks
$ jupyter notebook

Have fun!

You can now start editing the .js and .py files to see changes reflected in your local notebook. After changing files in the js folder, the local start script will recompile the js files and put them in to keplergl/static folder. You need to reload the jupyter notebook page to reload the files.